I'm new to symfony and twig. I want to build my html forms using BootStrap CSS Framework. So my form looks like this in twig file:
<form action="{{ path('register')}}" class="form-horizontal span10 offset7" id="frmRegistration" method="POST" {{ form_enctype(form) }} novalidate>
<fieldset>
{{ form_widget(form._token) }}
<div class="control-group">
{{ form_label(form.userName, null, {'label_attr': {'class':'control-label'}})}}
<div class="controls">
{{ form_widget(form.userName, {'attr': {'data-path': path('ajax_user_exists') } }) }}
</div>
</div>
<div class="control-group">
{{ form_label(form.password.first, null, {'label_attr': {'class':'control-label'}})}}
<div class="controls">
{{ form_widget(form.password.first) }}
</div>
</div>
<div class="control-group">
{{ form_label(form.password.second, null, {'label_attr': {'class':'control-label'}})}}
<div class="controls">
{{ form_widget(form.password.second) }}
</div>
</div>
<div class="control-group">
<div class="controls">
<input id="register_submit" type="submit" value="تاييد" class="btn btn-primary" />
</div>
</div>
</fieldset>
Now I want to show validation error messages exactly in front of each input. My problem is that how can I do this using twig? If I use {{ form_row(form.firstName) }} it will generate the label and input. But I cant wrap them inside the Bootstrap form structure. Any help is appreciated in advance.
UPDATE
Sorry for not being precise when reading symfony documentation. I found the solution. Using {{ form_errors(form.firstName) }} solved the problem.
{{ form_error(form.firstName) }}?form_error()is different fromform_errors().