6

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!

  • 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 Feb 16 '17 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.. – Juraj Nemec Feb 16 '17 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 – 4k4 Feb 16 '17 at 14:52
  • @JurajNemec Did you find any solution for this? – Dinesh Patil Feb 26 '19 at 7:50
4

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

| improve this answer | |
0

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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