I've the following Model in Symfony2 due to the fact that the relationship has an extra property(Boolean value) and as such must be represented as an entity too.
I'm now working on the form to mark the completion of Trainings for the various Candidates (Parents) having attended.
I'm using a nested form as follow:
class TrainingCompletionType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('titre', 'text', array('disabled' => 'true'))
->add('Intervenant', 'collection', array(
'type' => new TrainingCandidatesType(),'label'=>'Candidat(s)'
,'options' => array('label'=>' '))
);
}
Here is the TrainingCandidatesType form
class TrainingCandidatesType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('parents','entity',array('class'=>'ParentsBundle:Parents'
,'label'=>' ','disabled'=>true))
->add('completed')
;
}
This works (the submission of parents checked a completed), however it causes the twig to render each parent as a drop-down list having each and every parents as a value as seen below
. I've disabled the drop-down since the user is not made to select from the list. The candidates name is not meant to be selectable.
Is there a way to display each of the parent name as a label or disable text input in Symfony without referring to a data transformer or Event subscriber?
I've gone through related questions on the Stack site but didn't find one quite similar to this issue.
Is there a better approach to this that i'm willing to try ? or am i approaching it from a worng angle?