【发布时间】:2014-11-06 16:38:34
【问题描述】:
如何检索刚刚验证过的表单的值?但我想操纵控制器中的值。我有这段代码来检索信息,但没有在控制器 php 中处理。
if ($form->isValid ()) {
$recuperacion = $form->getData ();
$em = $this->getDoctrine ()->getManager ();
$em->persist ( $recuperacion ); // Inserta la información en la base de datos
$em->flush ();
/* I want get the values here... */
/* _____________________________ */
$this->InsertarAdminPV ( $user );
return $this->redirect ( $this->generateUrl ( 'md_listapv' ) );
}
谢谢!
【问题讨论】:
-
“但未在控制器 php 中处理”是什么意思?你能告诉我们你是如何创建表单和处理请求的吗?
-
1.你已经用
$recuperacion = $form->getData ();得到了它们,那有什么问题呢? 2.$request->request->get($form->getName())没有帮助? -
你能贴出getData()的代码吗? ?
-
如果您在调用
$form->isValid()之前执行了$form->handleRequest($request),您甚至不需要$form->getData()函数,因为表单处理程序会将表单值保存到您在@987654327 中定义的对象中@ 自动地。如果您想获取这些值,只需使用您创建的实体提供的辅助函数即可。
标签: php symfony web doctrine-orm