Drupal 8 Allowed Formats Module

By shane
Mon, 2019-09-02 13:19
comments
Daily Dose of Drupal Episode #229

Share with Others

The Drupal 8 Allowed Formats module allows you to configure what text formats are available for each field. By default, all the text formats a user has permission to use are available for every field that uses text formats. Sometimes you want a field to have html, but have a more limited set of html tags. This can easily be accomplished by creating a new text format and using the Allowed Formats module to limit the field to using that text format.

Download the Drupal 8 Allowed Formats module.

composer require drupal/allowed_formats

Install the Drupal 8 Allowed Formats module.

Go to Admin > Structure > Content Types and select Manage Fields. If you edit the Body field you will see an Allowed formats section that allows you to specify what formats you can use on this

Allowed formats checkboxes

This means you could easily create a new field on a content type and set it to only allow the Restricted HTML text format. You could also create a new text format that could be used on specific text fields.