I have a entity mapped to a form, but I don't want to have all fields editable, but still want to show the value.
For example this is my form type:
class GameHasPlayerType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('inTeam', new TeamPositioningCheckboxType())
->add('positionX', new TeamPositioningNumberType(), array(
'attr' => array(
'class' => 'in-table'
)
))
->add('positionY', new TeamPositioningNumberType(), array(
'attr' => array(
'class' => 'in-table'
)
))
->add('exchanged', new TeamPositioningCheckboxType())
;
}
}
This type has a custom form template:
{% block team_positioning_widget %}
{% spaceless %}
<td>
{{ form_widget(form.inTeam) }}
</td>
<td>
{{ form.player.firstName }} {# Player is not in the form, but inside the mapped entity #}
</td>
{% endspaceless %}
{% endblock %}
From the form I want to reference to the mapped entity and access fields that are not added to the form.
How can I access the mapped entity from the form object?