Anonymous Anonymous - 6 months ago
248 0

To add a property in an entity that is used in a form, but you do not want any doctrine mapping, use the mapping => false option.

PHP

Symfony2 Doctrine2 add entity property in form without doctrine mapping

Embed
$builder->add(
            'gender',
            'choice',
            array(
                'mapped' => false,
                'required' => true,
                'choices' => array(
                    'M' => 'Dhr.',
                    'F' => 'Mevr.'
                ),
                'label' => 'Dhr. / Mevr.'
            )
        );
Comments