symfony 2 form表单和doctrine 问题求助
时间:2011-09-08
来源:互联网
我要实现自分类功能,现在的form表单中有一个parent项,以及isRoot项,产品分类类中这样定义:
/**
* @var string $parent
* @ORM\ManyToOne(targetEntity="ProductCategory")
* @ORM\JoinColumn(name="product_category_id", referencedColumnName="id")
*/
private $parent;
提取表单内容并插入数据库:
$entity = new ProductCategory();
$request = $this->getRequest();
$form = $this->createForm(new ProductCategoryType(), $entity);
$form->bindRequest($request);
//如果多选按钮(checkbox) isRoot选中,将parent置为NONE
if($entity->getIsRoot()){
$entity ->setParent('NONE');
}
if ($form->isValid()) {
$em = $this->getDoctrine()->getEntityManager();
$em->persist($entity);
$em->flush();
return $this->redirect($this->generateUrl('product_category_show', array('id' => $entity->getId())));
经过验证,在$em->flush();执行时出现错误:
Warning: spl_object_hash() expects parameter 1 to be object, string given in /.../vendor/doctrine/lib/Doctrine/ORM/UnitOfWork.php line 1073
请问下这是什么问题,该如何解决呢?先谢了^_^
/**
* @var string $parent
* @ORM\ManyToOne(targetEntity="ProductCategory")
* @ORM\JoinColumn(name="product_category_id", referencedColumnName="id")
*/
private $parent;
提取表单内容并插入数据库:
$entity = new ProductCategory();
$request = $this->getRequest();
$form = $this->createForm(new ProductCategoryType(), $entity);
$form->bindRequest($request);
//如果多选按钮(checkbox) isRoot选中,将parent置为NONE
if($entity->getIsRoot()){
$entity ->setParent('NONE');
}
if ($form->isValid()) {
$em = $this->getDoctrine()->getEntityManager();
$em->persist($entity);
$em->flush();
return $this->redirect($this->generateUrl('product_category_show', array('id' => $entity->getId())));
经过验证,在$em->flush();执行时出现错误:
Warning: spl_object_hash() expects parameter 1 to be object, string given in /.../vendor/doctrine/lib/Doctrine/ORM/UnitOfWork.php line 1073
请问下这是什么问题,该如何解决呢?先谢了^_^
作者: pinaby 发布时间: 2011-09-08
upup!!
作者: wang_youyu 发布时间: 2011-09-09
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28