egeloen / IvoryCKEditorBundle

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

Required field not rendered #305

Closed flim closed 7 years ago

flim commented 7 years ago

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

egeloen commented 7 years ago

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 7 years ago

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 7 years ago

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

Im using Symfony 3.3 IvoryCKEditorBundle master

Thanks

egeloen commented 7 years ago

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.

egeloen commented 7 years ago

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

egeloen commented 7 years ago

Closing as the bundle renders the appropriate html 5 attribute.

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(),
            ]
        ])