How to write a custom form field in Symfony2 ? In this form you should see:
- A Dropdown field with the label City;
- Another field of type number next to the label port number.
How to write a custom form field in Symfony2 ? In this form you should see:
You have two options:
1 - Place the fields manually inside the form and pick up the parameters via $ request inside the controller.
HTML
{{ form_start(form) }}
<select name='cidades'>
<option value="">Selecione a Cidade</option>
{% for cidade in cidades %}
<option value="{{cidade.id}}">{{cidade.nome}}</option>
{% endfor %}
</select>
{{ form_end(form) }}
Controller:
$request->request->get('cidades');
2 - Use Symfony standard mode and work the Form with ArrayCollection.