title: How to fix the size of field to maxlength using form_widget
body: <p>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</p>
  
  <p>I have tried :</p>
  
  <pre><code> {{ 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'  }}) }}
  </code></pre>
  
  <p>How could I limit the number of digits before validation?</p>
  
  <p><strong>update:still not working</strong></p>
  
  <p>this is my form builder</p>
  
  <pre><code>-&gt;add('telMobile', null,array('label' =&gt; 'common.label.telmobile', 'required' =&gt; true ,'attr' =&gt; ['pattern' =&gt; '/^[0-9]{8}$/']))
  </code></pre>
  
  <p>and I have tried also to add the pattern to the widget :</p>
  
  <pre><code> {{ form_widget(form.telMobile, {'attr':{'class': 'form-control','placeholder' :'Téléphone mobile - 8 chiffres', pattern' : '/^[0-9]{8}$/' }}) }}
  </code></pre>
  
  <p>as you see in the picture I still can type more than 8 digits</p>
  
  <p><a href="https://i.stack.imgur.com/C4epu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/C4epu.png" alt="enter image description here"></a></p>