7

I have one content type, where I want to restrict the body field to plain text only. In Drupal 7, there was an option to set the plain text format explicitly in field configuration; however in Drupal 8, there is no "plain text" option in the select box. I cannot change user permissions to text formats, because I want to have plain text for the administrator as well.

In Drupal 7:

enter image description here

In Drupal 8:

enter image description here

So please, how to force the plain text in body field? Do I have to create a new text format? If so, why such a nonsense (my desired text format already exists, but cannot be used)?

Thanks!

4
  • Does plain text exist as a text format? Are these screens from user 1? Do you have any custom code that might manipulate the options?
    – Kevin
    Commented Feb 16, 2017 at 14:23
  • @Kevin yes, plain text format exists. These screens are from user 1 (administrator). No custom code. I suppose, that this has something to do with comment by plain text format in Drupal 8, which states This format is shown when no other formats are available. But again, I do not see any logic here for this behavior.. Commented Feb 16, 2017 at 14:29
  • @JurajNemec, it should work, if you reset the text formats and permissions to default and use Allowed Formats to restrict the format to Plain Text in the field. See my answer
    – 4uk4
    Commented Feb 16, 2017 at 14:52
  • @JurajNemec Did you find any solution for this? Commented Feb 26, 2019 at 7:50

4 Answers 4

6

See the issue Allow text field to enforce a specific text format. You can use the patch from this issue or install the module Allowed Formats which provides these options in the text field configuration:

enter image description here

1

You've got a good point. I don't know why the built in plain text format is disabled unless all other formats are deleted ... "This format is shown when no other formats are available."

I couldn't find an answer for it's disabled either.

So you have to create a new plain text format.

All you have to do is go to admin/config/content/formats. Then Add text format. Then fill out the next screen and set Display any HTML as plain text.

0

In Drupal 8 Just add new plain text format by giving the extra space between plain and text label it will create the new one for you.

0

You can fix this with a hidden config option (not present in the GUI). You can set it from drush:

drush cset filter.settings always_show_fallback_choice TRUE

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.