dt4233 2016-12-01 01:43
浏览 133

警告:preg_match()期望参数2为字符串,对象为ERROR Symfony 3

I was doing a simple update operation when this error occurred. The update operation is done but when I tried to get back to see the modification on the page I get this error below:

Warning: preg_match() expects parameter 2 to be string, object given

This is my Twig Code:

<form class="form-horizontal" method="post" action="{{ path('Update_comment',{'idc':comment.id}) }}">
    <div class="control-group">
         <label class="control-label" for="inputPassword">New Comment <sup>*</sup></label>
         <div class="controls">
              <textarea name="contenu" cols="2" rows="20"></textarea>
         </div>
    </div>
    <div class="control-group">
         <div class="controls">
              <button type="submit" class="btn btn-success">
                    <i class=" icon-pencil"></i>Edit
              </button>
         </div>
    </div>
</form>

This is my Action's code:

public function UpdateCommentAction($idc){
    $em = $this->getDoctrine()->getManager();

    $cmt = $em->getRepository('MyAppUserBundle:PostComment')->find($idc);
    $idPost=$cmt->getIdPost();

    if ($cmt != null) {
        if (isset($_POST['contenu'])) {
            $cmt->setContenu($_POST['contenu']);

            $em->flush();
        }
    }

    return $this->redirectToRoute("get_view_post", array('id' => $idPost));
}

and these are my routing's configuration:

get_view_post:
   path:     /blog/get/one/post/{id}/
   defaults: { _controller: "MyAppBlogBundle:Blog:getpost" }
Update_comment:
   path:     /blog/get/post/Comment/Update/View/{idc}
   defaults: { _controller: "MyAppBlogBundle:Blog:UpdateComment" }

I don't know where is the problem, especially that the Updation operation is working.

  • 写回答

1条回答 默认 最新

  • douhezhang8932 2016-12-01 04:18
    关注

    Can you run this from the command line in your Symfony project's root directory:

    php bin/console cache:clear --env=prod
    

    I suspect maybe you made changes and they are still cached. Unless there's something else you haven't told us? I can't see where else that message comes from because you don't have preg_match anywhere.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度