I want to throw an error after binding the form. Here my code:
$form = $this->createFormBuilder()
...
->add('date', 'birthday', array(
'years' => range($year_18-90, $year_18),
'empty_value' => array('year' => $year_18-16)
))->getForm;
//Post and valid
if ($form->isValid()) {
$formData = $form->getData();
if ($formData['date']->getTimestamp() > $date_18) {
//if user is under 18, then throw an error in from 'date' / ' birthday'
}
How can I do it in symfony2 after Method-Post?