n How to add input format to textarea in drupal 8 | CodimTh

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.

 

Riadh Rahmi

Senior Web Developer PHP/Drupal & Laravel

I am a senior web developer, I have experience in planning and developing large scale dynamic web solutions especially in Drupal & Laravel.

Web Posts

Search

Page Facebook