I am working on a Symfony 3.3 application that uses Sonata.
I want to limit the length of a string that can be entered into a ckeditor instance.
I add the following in my admin class:
->add('caption', 'ckeditor', [
'required'=>false,
'label' => 'media.caption',
])
... and then I get stuck, not knowing how to proceed.
Is there a simple way to get the application to politely tell the user that his text needs to be shorter?
I ended up adding the following at the end of my admin class, per this page:
public function validate(ErrorElement $errorElement, $object)
{
$errorElement
->with('caption')
->assertLength(['max' => 32])
->end()
;
}