SF2 form : error Neither the property … nor one of the methods “get

Your error is correct and telling you that you entity Contact does not have the contact property and no related getter setter method while in your buildForm() you have used contact property like $builder->add('contact'); but there is no related property exists in the entity,Define the property first in your entity

class Contact {
  protected $nom;
  protected $courriel;
  protected $sujet;
  protected $msg;
  protected $contact;

public function getContact() {
  return $this->contact;
}

public function setContact($contact) {
  $this->contact= $contact;
}
/* ...
remaining methods in entity 

*/
}

or if its a non mapped field then you have to define this field in builder as non mapped

$builder->add('contact','text',array('mapped'=>false));

By defining above you will not need to update your entity

Leave a Comment