Problem: I have a field in my schema that needs to have a value but I cannot make the user input the value in the form. I have to insert it when I am saving the object instance in the database. I can assign a value for this field using the user entered data in the form. How can I do this
Example: For examples sake say I have a filed called FullName, which I have to assign using the user inputs FirstName and LastName.
So basically FullName = FirstName + " " + LastName.
Solution: Use a event listner provided by the formBuilder object.
$formMapper->getFormBuilder()->addEventListener(FormEvents::SUBMIT, function(FormEvent $event) { $solicitor = $event->getData(); $solicitor->setFullName($solicitor->getFirstName() . ' '. $solicitor->getLastName()); });
References: http://symfony.com/doc/current/form/events.html