vendredi 29 janvier 2016

Symfony2: Set label of checkbox from Class Field

I have a Class with 3 fields:

$id, $name, $isChecked

I have a formtype and I want, that the label of the $id field is the $name field. Is that possible?

/**
     * @param FormBuilderInterface $builder
     * @param array $options
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('id')
            ->add('name')
            ->add('is_checked', 'checkbox', array(
                'required' => false,
                'label' => //This should be the $name field
            ));
        ;
    }




Aucun commentaire:

Enregistrer un commentaire