내가 내 컨트롤러에서이 코드가 실행되지 않습니다 : 내가 /account/new
를 호출 할 때컨트롤러는 응답을 반환해야 작업이
/**
* Displays a form to create a new Bank Account
*
* @Route("/account/new", name="wba_new")
* @Method("GET")
* @Template("BankBundle:BankAccount:new.html.twig")
*/
public function newBankAccountAction() {
$entity = new Account();
$form = $this->createForm(new AccountType(), $entity);
return array('entity' => $entity, 'form' => $form->createView());
}
/**
* Handle bank account creation
*
* @Route("/", name="wba_create")
* @Method("POST")
*/
public function createAction(Request $request) {
$entity = new Account();
$form = $this->createForm(new AccountType(), $entity);
$form->handleRequest($request);
print_r($request);
exit;
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($entity);
$em->flush();
return $this->redirect($this->generateUrl('wba_list'));
}
return array('entity' => $entity, 'form' => $form->createView());
}
양식이 아무 문제없이 보여 주었다과 행동이 /
로 이동되지만를 나는를 보낼 때 양식이 오류가 발생했습니다 :
The controller must return a response (Array(entity => Object(BankBundle\Entity\AccountType), form => Object(Symfony\Component\Form\FormView)) given).
왜? 내 코드에서 무엇이 잘못 되었습니까? 문제 상황을 해결하는 것은 읽기 후
어떤 종류의'Response' 객체를 반환 할 컨트롤러 액션이 아닌가? –
@JoachimIsaksson 항상 그렇지는 않습니다. 내 에디션을 참조하십시오. – Reynier
@JoachimIsaksson이 옳습니다. 'createAction()'함수 위에'@ Template' 주석을 잊어 버렸습니다. – cheesemacfly