Faloude Faloude - 1 month ago 15
PHP Question

SilverStripe character limit for TextareaField

There seems to be no

maxLength
parameter for
TextareaField
as there are for
TextField
.

What's a good way to limit characters for
TextareaField
?

Answer

Faloude, try doing something like $yourTextarea = TextareaField::create('yourField')->setAttribute('maxlength', 15);

You can set attributes on a form field if there isn't a pre-defined method for it in SilverStripe in this way.

Comments