【发布时间】:2016-03-16 07:43:47
【问题描述】:
早上好,
我从数据库中选择了一行来编辑它
$object_before_edit=$this->getDoctrine()->getManager()->getRepository('MyBundle:MyClass')->find($object_id);
$form = $this->createForm(new MyClassType(), $object_before_edit);
$form->handleRequest($request);
if ($form->isValid()) {
// I modified this 2 fields in form
dump($form['fielda']->getData()) . "<br/>";// line 1
dump($form['fieldb']->getData()). "<br/>";// line 2
// but here i want to see the object in the database before doing
// persist and flush
dump($object_before_edit->getFielda()) . "<br/>";// line 3
dump($object_before_edit->getFieldb());// line 4
die();
}
在我的数据库中:
fielda = 1
字段b = 2
我改变它的形式:
fielda = 3
字段b = 4
所以在我看到的转储中:
line 1 : 3 // 它的逻辑
line 2 : 4 // 它的逻辑
第 3 行:3 // 为什么???
第 4 行:4 // 为什么???
通常代码显示数据库中的值而不是表单
【问题讨论】:
标签: php validation symfony doctrine-orm