有一个类似的问题,但它可能已经过时了,因为它说它适用于 Symfony 2.0。Symfony2 表单事件的描述?
Symfony2 2.3 支持以下事件:
const PRE_SUBMIT = 'form.pre_bind';
const SUBMIT = 'form.bind';
const POST_SUBMIT = 'form.post_bind';
const PRE_SET_DATA = 'form.pre_set_data';
const POST_SET_DATA = 'form.post_set_data';
在下面的 Symfony 书中显示的示例中,这些事件是什么时候触发的?
public function newAction(Request $request)
{
// just setup a fresh $task object (remove the dummy data)
$task = new Task();
$form = $this->createFormBuilder($task)
->add('task', 'text')
->add('dueDate', 'date')
->add('save', 'submit')
->getForm();
$form->handleRequest($request);
if ($form->isValid()) {
// perform some action, such as saving the task to the database
return $this->redirect($this->generateUrl('task_success'));
}
// ...
}