0

I am in a need of the Drupal 7 functionality where I could select specific input format for specific field whereas in Drupal 8 this is based on permissions and I really dislike it and for a specific project I need the good old D7 behavior.

Right now I have to alter the input format's static cache during page load to achieve the goal of providing specific input format but it is very bad approach but I haven't found an easy way to do this yet.

Better yet, I need this for my custom form, not even a field but the permissions still apply so Field API has nothing to do with it but rather how the input formats and the text format element are tied together.

FYI this is my solution right now(it is ES service):

    $route_name = $this->routeMatch->getRouteName();
    $routes = [
      ...
    ];

    if (in_array($route_name, $routes)) {
      filter_formats($this->user);
      $formats = &drupal_static('filter_formats', []);
      $formats['user'][$this->user->id()] = [
        'my_format' => $formats['all']['my_format']
      ];
    }
  }

1 Answer 1

1

The way I recently did this on a Drupal 8 site was to use Better Formats.

https://www.drupal.org/project/better_formats

You can force filter format per field - one option = no select box. Even for admins.

If you are using Paragraphs, you will also need this patch.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.