egeloen/IvoryCKEditorBundle

Required field not rendered

Closed this issue · 7 comments

flim commented

Im using
Symfony 3.3
IvoryCKEditorBundle 4.0.6

And my field

->add('description', CKEditorType::class, ['required' => true]);

doesn't render as required for the html validation.

Even if I add on the twig as

{{ form_widget(form.description, {'required': 'required'}) }}

It is a version issue ?

Thanks

PS: a similar issue exists #148

Hum, a long time ago, I have fixed it with a8a9a7e in the 2.1.6 version of the bundle. Can you check if the required flag is rendered on your textarea?

flim commented

Thanks for coming back here :)
I already checked, there is no required attribute on the html.
The current CKEditorType doesn't looks the same as your commit.

Muspi commented

Hello, I have the same problem here, required is not rendered.

Im using
Symfony 3.3
IvoryCKEditorBundle master

Thanks

So, I just give a try to your issue and the required attr is rendered on the textarea when you take a look to the source page but then CKEditor removes it dynamically...

IMO this behavior should be reported to the CKEditor team as the bundle does the right thing whereas CKEditor seems removing the attr and don't take it into account.

Can someone open an issue on the CKEditor bugtracker as it looks like a regression to me?

Closing as the bundle renders the appropriate html 5 attribute.

you can add a constraint to form builder:

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