symfony 2 form表单和doctrine 问题求助

pinaby 2011-09-08 04:39:28
我要实现自分类功能,现在的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
请问下这是什么问题,该如何解决呢?先谢了^_^
...全文
214 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
wang_youyu 2011-09-09
  • 打赏
  • 举报
回复
upup!!

4,251

社区成员

发帖
与我相关
我的任务
社区描述
国内外优秀PHP框架讨论学习
社区管理员
  • Framework
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧