Symfony3 allow_extra_fields

Viewed 4716

I'm trying to add two extra fields to a form:

$this->contactForm = $this->createFormBuilder($contact, array('allow_extra_fields' =>true))
->add('Nom',        TextType::class)
->add('Prenom',     TextType::class)
->add('Telephone',  TextType::class, array(
    'label' => 'Téléphone'))
->add('Email',      TextType::class)
->add('Ajouter',    SubmitType::class)
->getForm();

But I get this error:

Neither the property "Nom" nor one of the methods "getNom()", "nom()", "isNom()", "hasNom()", "__get()" exist and have public access in class "CommonBundle\Entity\Contact".

How can I prevent this error?

1 Answers
Related