After updating Drupal from version 8.0.0-beta7 to version 8.0.x-dev — to fix text_format fields not submitting their value due to a missing name attribute —, my field is now displaying as a basic input field with the format bar under it.

Here's the code that defines the content field of my entity (inside the baseFieldDefinitions method):

$fields['content'] = BaseFieldDefinition::create('text')
  ->setDescription(t('The content of the block'))
    'max_length'  => 1024
  ->setDisplayOptions('form', array(
    'type'   => 'text_format',
    'weight' => -6
  ->setDisplayConfigurable('form', TRUE);

As said above, this code works fine on the latest beta but breaks on the latest version from GitHub.

Expected result (8.0.0-beta7):

enter image description here

Obtained result (8.0.x-dev):

enter image description here

I had submitted a bug report, thinking this was a bug, but apparently it isn't. I was told I need to use a textarea for the editor to show up. The thing is... text_format defaults to a textarea.

I'm guessing there's something I'm not doing right here, but after hours of searching, I just can't seem to understand what. I've tried changing the type passed to BaseFieldDefinition::create() to string_long, too, but then I just get a textarea with no format.

1 Answer 1


Here is the correct code to create a WYSIWYG field:

$fields['title'] = BaseFieldDefinition::create('text_long')
  ->setDescription(t('The content of the block'))
  ->setDisplayOptions('form', [
      'type' => 'text_textarea',
  ->setDisplayOptions('view', [
      'type' => 'text_default',
  ->setDisplayConfigurable('form', TRUE)
  ->setDisplayConfigurable('view', TRUE);
  • The fix for those fields was to disable ckeditor, because it doesn't support textfields. If you want an editor, use text_long as correctly suggested by the answer. also note that there's no text_format widget, never was, it only works because it falls back to the default.
    – Berdir
    Mar 9, 2015 at 21:53
  • I guess I still have a long way to go before fully understanding Drupal. Thanks for the clarification, works like a charm now!
    – PLPeeters
    Mar 10, 2015 at 9:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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