egeloen / IvoryCKEditorBundle

Provides a CKEditor integration for your Symfony project.
MIT License
336 stars 114 forks source link

Attribute required doesn't work #309

Closed davidskaraboo closed 7 years ago

davidskaraboo commented 7 years ago

Hi mates! I am adding the required attribute in form type but doesn't appear in the textarea.... some solution?

Symfony 3.4

The code:

'content' => [
                        'required' => true,
                        'field_type' => CKEditorType::class,
                        'config' => array(
                            'toolbar' => 'default'
                        )
               ],
egeloen commented 7 years ago

Duplicate of #305

To resume, it seems there is a bug in CKEditor as the bundle renders the HTML5 required attribute and then, CKEditor removes it from the DOM and don't do anything with it...

imajim commented 4 years ago

you can add a constraint to form builder:

$builder->add('description', CKEditorType::class, [
            'label' => 'Description',
            'config' => ['toolbar' => 'basic'],
            'required' => true,
            'constraints'=>[
                new NotBlank(),
            ]
        ])