This field creates a JavaScript-based WYSIWYG editor based on the Trix editor to manage long texts.
In :ref:`form pages (edit and new) <crud-pages>` it looks like this:
Tip
EasyAdmin provides other fields for long text contents: :doc:`TextAreaField </fields/TextareaField>` is ideal for long contents that don't need any formatting; :doc:`CodeEditorField </fields/CodeEditorField>` is ideal to edit and store any kind of source code.
PHP Class:
EasyCorp\Bundle\EasyAdminBundle\Field\TextEditorFieldDoctrine DBAL Type used to store this value:
textSymfony Form Type used to render the field: TextEditorType, which is based on Symfony's TextareaType
Rendered as:
<!-- when loading the page this is transformed into a WYSIWYG editor via JavaScript --> <textarea> ... </textarea>
The height of the editor used in form pages (new and edit) is as large
as needed to display its contents. This height also grows dynamically (via JavaScript)
to always match the number of rows of its contents.
This option sets the number of rows displayed when the field contents are empty. By default, the initial height is small, so it's a good idea to increase this value when the expected content is much longer (e.g. a blog post):
yield TextEditorField::new('...')->setNumOfRows(30);
This option allows you to pass a PHP array of the configuration options to set or update in the JavaScript Trix editor used by this field:
yield TextEditorField::new('...')->setTrixEditorConfig([
'blockAttributes' => [
'default' => ['tagName' => 'p'],
'heading1' => ['tagName' => 'h2'],
],
'css' => [
'attachment' => 'admin_file_field_attachment',
],
]);
Check out the src/trix/config/ folder at Trix editor repository to learn about all the available configuration options.
