Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Description
The text_format
field doesn't display a full editor anymore, only a basic input field. In the beta7 version, it displays the editor correctly but doesn't save. The latest 8.0.x-dev version inverts that bug (it saves the contents of the field, but doesn't display correctly — same code).
Steps to reproduce
- Install Drupal 8.0.x-dev
- Create an entity
- Configure the add route for the entity
-
Put the following code in the
baseFieldDefinitions
method for the entity:$fields['content'] = BaseFieldDefinition::create('text') ->setLabel(t('Content')) ->setDescription(t('The content of the block')) ->setSettings(array( 'max_length' => 1024 )) ->setDisplayOptions('form', array( 'type' => 'text_format', 'weight' => -6 )) ->setRequired(TRUE) ->setDisplayConfigurable('form', TRUE);
- Go to the add page for the entity, see the result
- Update composer.json by changing the
drupal/core
version to"~8.0"
- Run
composer update
and clear cache - Go to the add page again and see the field displaying just fine
Expected result (display on 8.0.0-beta7)
Obtained result (display on 8.0.x-dev)
Comment | File | Size | Author |
---|---|---|---|
Screen Shot 2015-03-06 at 12.07.07.png | 28.56 KB | PLPeeters | |
Screen Shot 2015-03-06 at 11.59.23.png | 15.92 KB | PLPeeters |
Comments
Comment #1
idebr CreditAttribution: idebr commented@PLPeeters thanks for submitting a bug report! The editor was purposefully removed because CKEditor is currently only compatible with
textarea
(and incompatible withtextfield
). For more information, please have a look at the issue where this was resolved: #2442255: Changing text formats on a field makes it impossible to edit.Comment #2
PLPeeters CreditAttribution: PLPeeters commented@idebr Thanks for clearing that up. Reading through the comments, I noticed it's still possible to attach an editor, but I couldn't understand how. Could you tell me where I can figure that out?
Comment #3
idebr CreditAttribution: idebr commented@PLPeeters The possibilities suggested in #2442255: Changing text formats on a field makes it impossible to edit. are either:
- Use a WYSIWYG editor that is compatible with a textfield (eg. not CKEditor)
- Use a textarea instead of a textfield to use CKEditor
Comment #4
PLPeeters CreditAttribution: PLPeeters commented@idebr Using a textarea seems to be the appropriate option in my case, however the description for
text_format
in the documentation for the Form API is "A text-format-enabled version of a textarea", so apparently it's already supposed to be a textarea. I guess there's something I'm not understanding correctly here. Could you enlighten me?Comment #5
PLPeeters CreditAttribution: PLPeeters commentedJust for the record for anyone who might stumble across this problem in the future, the solution was to change the definition of my field to
text_long
and the type totext_textarea
, like this:Comment #6
michael.romero CreditAttribution: michael.romero commentedconfiguration to have a field with full editor (Textarea):