I\'m rendering a form in Symfony2 with data_class mapped to Reservation
entity, and this form has a entity field type, of class Service
. The relati
I suppose the only way to do that is override rendering in the template. You should pass to your template entity MyBundle:Service
and render it for example like this:
{% for service in services %}
<b>{{ service.name }}</b><br>
{% for option in service.options %}
<label>
<input type="checkbox" name="form_type_name[options][{{ option.id }}]" value="{{ option.id }}" {% if option in user.services.options %}checked="checked"{% endif %}>
{{ option.name }}
</label>
{% endfor %}
{% endfor %}
This can be solved by using the group_by option:
$builder->add('services','entity', array(
'class' => 'MyBundle:Service',
'group_by' => 'serviceType',
'multiple' => true,
'expanded' => true
));