Please Disable Your Browser Adblock Extension for our site and Refresh This Page!

our ads are user friendly, we do not serve popup ads. We serve responsible ads!

Refresh Page
Skip to main content
On . By CodimTh
Category:

Code snippet that can use to add input format to textarea in drupal 8.

$form['description'] = [
  '#type' => 'text_format',
  '#format' => 'full_html',
  '#title' => $this->t('Description'),
  '#default_value' => $config->get('description') ? $config->get('description') : '',
];

the result is like this:

textformat field

also there are others Properties:

  • #base_type: The form element #type to use for the 'value' element. 'textarea' by default.
  • #format: (optional) The text format ID to preselect. If omitted, the default format for the current user will be used.
  • #allowed_formats: (optional) An array of text format IDs that are available for this element. If omitted, all text formats that the current user has access to will be allowed.

 

Comments

Add new comment

Restricted HTML

Search

Page Facebook

Become a patron

If you need some help or you search a Drupal freelancer don't hesitate to contact us.

 

Contact Us

All the content is FREE but I still need your help

 

Become a patreon