3

I make a custom Entity content module, and for a field i want ckEditor.

Here my code for this field :

$fields['description'] = BaseFieldDefinition::create('string_long')
    ->setLabel(t('Description'))
    ->setRequired(true)
    ->setDisplayOptions('view', array(
        'label' => 'above',
        'type' => 'string_textarea',
        'weight' => -4,

    ))
    ->setDisplayOptions('form', array(
        'type' => 'string_textarea',
        'weight' => -4,
        'settings' => array(
            'placeholder' => 'Description de votre annonce',
        ),
    ))
    ->setDisplayConfigurable('view', TRUE)
    ->setDisplayConfigurable('form', TRUE);

Type : string_textarea

How can i tell Drupal 8 to get the widget for textarea basic html mode ?

5

There are 4 different field types that contain a text

  • string
  • string_long
  • text
  • text_long

What long means should be obvious, the difference between string and text is that text has a format (like full_html or basic_html) while string is always plain text.

You are currently using string_long, it doesn't make sense to show a wyswiwyg editor for that, since it would always escape all HTML. Use text_long instead.

  • Thank you, i was searching for this type text_long.... i don't find any doc on where are all the type. – Kevin Sep 10 '15 at 11:28
  • Is it possible to also select the default format? Can't really find anything about this. – Bram May 27 at 10:03

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.