2016-08-13 5 views
0

젠드 프레임 워크 3 튜토리얼을 시도 중이며 the in-depth part (Blog case)의 기능을 "편집"하는 데 어려움을 겪고 있습니다.젠드 프레임 워크 3 튜토리얼

블로그 메시지를 편집 할 때 편집 양식에 원본 메시지가 표시되지 않습니다. 원래 메시지를 양식에 바인딩 할 수없는 것 같습니다.

모든 샘플 코드를 복사했습니다. 나는 그것이 무엇이 잘못되었는지 모른다. 그건 그렇고, 내 추가 및 삭제 기능이 잘 작동합니다.

아무도 도와 줄 수 있습니까?

튜토리얼에서 editAction 방법 :

public function editAction() 
{ 
    $id = $this->params()->fromRoute('id'); 
    if (! $id) { 
     return $this->redirect()->toRoute('blog'); 
    } 
    try { 
     $post = $this->repository->findPost($id); 
    } catch (InvalidArgumentException $ex) { 
     return $this->redirect()->toRoute('blog'); 
    } 
    $this->form->bind($post); 
    $viewModel = new ViewModel(['form' => $this->form]); 
    $request = $this->getRequest(); 
    if (! $request->isPost()) { 
     return $viewModel; 
    } 
    $this->form->setData($request->getPost()); 
    if (! $this->form->isValid()) { 
     return $viewModel; 
    } 
    $post = $this->command->updatePost($post); 
    return $this->redirect()->toRoute(
     'blog/detail', 
     ['id' => $post->getId()] 
    ); 
} 
+0

당신의 코드를 포함하도록 질문을 편집 할 수 있습니다 컨트롤러의'editAction' 함수는 무엇입니까? –

+0

안녕하세요, 귀하의 회신에 감사드립니다. – Stwo

+0

PostForm.phtml에서 올바른 init() 함수로 문제점을 수정했습니다. 감사. – Stwo

답변

0

편집 코드 :보기에

if (! $request->isPost()) { 
    foreach($this->form->getMessages() as $message){ 
     $this->flashMessenger()->addErrorMessage($message['message']); 
    } 
} 

:

<?php echo $this->flashMessenger()->renderCurrent('error', ['options go here...']); ?>