I am using form_widget to render my field , what I want is to limit the digits to 5 (not to let the person type more then 8 digits ) somthing like maxlengh in html
I have tried :
{{ form_widget(form.telMobile, {'attr':{'class': 'form-control','placeholder' :'number - 8 digits', 'size' : '8' }}) }}
{{ form_widget(form.telMobile, {'attr':{'class': 'form-control','placeholder' :'number - 8 digits', 'maxlength' : '8' }}) }}
How could I limit the number of digits before validation?
update:still not working
this is my form builder
->add('telMobile', null,array('label' => 'common.label.telmobile', 'required' => true ,'attr' => ['pattern' => '/^[0-9]{8}$/']))
and I have tried also to add the pattern to the widget :
{{ form_widget(form.telMobile, {'attr':{'class': 'form-control','placeholder' :'Téléphone mobile - 8 chiffres', pattern' : '/^[0-9]{8}$/' }}) }}
as you see in the picture I still can type more than 8 digits