Is it possible to display in another order than how I coded it in my builder?
For example:
$builder
->add('persno', 'text', array('required' => false, 'label' => 'Personel Number '))
->add('firstname', 'text', array('required' => false, 'label' => 'First name '))
->add('lastname', 'text', array('required' => false, 'label' => 'Last name '))
And my twig file:
{{ form_row(form.firstname) }}
{{ form_row(form.lastname) }}
{{ form_row(form.persno) }}
Actually my form is not not working, when I click on my submit button it does change of URL but does not send my form in a POST request. It does not even say that there were errors.
Thanks for your help!
EDIT:
I am not going to send all the code but here is how it looks like:
{{ form_start(form, {'attr': {'class': 'form-horizontal'}}) }}
{{ form_errors(form) }}
<div class="form-group">
{{ form_label(form.persno, "Personel Number", {'label_attr': {'class': 'col-sm-2 control-label'}}) }}
{{ form_errors(form.persno) }}
<div class="col-sm-2">
{{ form_widget(form.persno, {value: idm.persno, 'attr': {'class': 'form-control'}}) }}
</div>
{{ form_label(form.serverroomalerts, "Server Room Alerts", {'label_attr': {'class': 'col-sm-2 control-label'}}) }}
{{ form_errors(form.serverroomalerts) }}
<div class="col-sm-2">
{{ form_widget(form.serverroomalerts, {'attr': {'class': 'form-control'}}) }}
</div>
{{ form_label(form.cpc, "CPC", {'label_attr': {'class': 'col-sm-2 control-label'}}) }}
{{ form_errors(form.cpc) }}
<div class="col-sm-2">
{{ form_widget(form.cpc, {'attr': {'class': 'form-control'}}) }}
</div>
</div>
<div id="buttons" class="form-group">
<div class="col-sm-6 control-label">
{{ form_widget(form.submit, {'label': 'Save changes', 'attr': {'class': 'btn btn-lg btn-primary'}}) }}
</div>
</div>
{{ form_rest(form) }}
{{ form_end(form) }}
Personel Number, Server Room Alerts and CPC are not in the same order in my EntityType.php. I create my form like that :
$form = $this->get('form.factory')->createForm(new SciencePersonelAdhocType(), $science, array(
'action' => $this->generateUrl('admin_platform_edit'),
'method' => 'POST')))
->add('submit', 'submit');
Aucun commentaire:
Enregistrer un commentaire