2016-09-24 2 views
1

symfony의 exeption 및 일부 매개 변수에 문제가 있습니다. 수천 개의 코드를 검사하고 인터넷에서이 예외가 발생하는 이유를 전혀 알지 못합니다.Symfony2.7 : Twig render controller()가 내 매개 변수를 무시합니다.

는 예외입니다 :

예외가 템플릿의 렌더링 ("."슬러그 "일부 필수 매개 변수 (누락" ") 경로의 URL 생성"blogcomment_create을)에있는 동안 발생 된 @Blog \ 기본 라인에서 블로그 \의 singlePost.html.twig \ 29

경로 구성 :

blogcomment_create: 
    path: /{slug}/comment/create/ 
    defaults: { _controller: "BlogBundle:Comment:create" } 
    requirements: { methods: post } 

내 나뭇 가지 템플릿 내 코드 가져 오기 내 컨트롤러 :

<footer> 
    {{ render(controller('BlogBundle:Comment:create', { 
     'slug': Post.slugname 
    })) }} 
</footer> 

내 행동 선언 :이 예외 미친지기 시작

public function createAction(Request $request, $slug = null) 
{ 
    //... 
} 

내가 그녀를 얻고 난 정말 눈의 좋은 쌍을해야하는 이유, 내가 어떤 단서가 없다.

은 내가 exemples의 톤을 시도해보십시오

How to insert a Controller in Twig with "render" in Symfony 2.2?

symfony2 - twig - how to render a twig template from inside a twig template

Change template via parameter when render a controller action?

... 여기

fonction의 덤프

:

object(Symfony\Component\HttpKernel\Controller\ControllerReference)[992] 
    public 'controller' => 
     string 'BlogBundle:Comment:create' (length=31) 
    public 'attributes' => 
     array (size=1) 
      'slug' => string 'article-de-test-yolowowo' (length=24) 
    public 'query' => 
     array (size=0) 
      empty 

답변

0

좋습니다. 알겠습니다.

문제는 내 나뭇 가지 템플릿이 아니라 컨트롤러에 있습니다. 나는이 컨트롤러에서 폼을 생성하는 권한을 가지고있다. 내가이 fonction에 매개 변수를 전달하는 것을 잊었다

private function createCreateForm(Comment $entity, $slug) 
{ 
    $form = $this->createForm(new CommentType(), $entity, array(
     'action' => $this->generateUrl('blogcomment_create', array('slug' => $slug)), 
     'method' => 'POST', 
    )); 

    $form->add('submit', 'submit', array('label' => 'Create')); 

    return $form; 
} 

이 기능에 : 나는 나의 행동에 그녀를 호출합니다.

$this->generateUrl() 
정말> 내가 문제의 종류를 얻을 때 빨리 잠이 필요

>

내 문제가 앞으로 다른 사람들에게 도움이되기를 바랍니다.

관련 문제