I am submitting a symfony2 form, and I would like to set a certain Entity property to false if the email field for that entity was not filled and that property was submitted as 'true'.
I do this now by:
$myForm = $this->createForm(new FormType(), $myEntity);
$myForm->handleRequest($request);
if ($myForm->isValid()) {
if (!$myEntity->getEmail()) {
$myEntity->setProperty(false);
}
}
I would now expect the checkbox corresponding to the property to be uncheck when the form is displayed after being submitted. But the property checkbox in the form does not respond to that, it stays checked.
Does anyone know how to do this properly?