Dodzik
Dodzik

Reputation: 370

Catchable Fatal Error: Argument 3 passed to Symfony::render() must be an instance of Symfony\..\Response, array given

I want to pass 2 arrays into render function in controller.

How do I do that?

For now I have something like that:

class GradebookController extends Controller
{
    /**
     * @Route("/gradebook", name="_gradebook")
     */
    public function indexAction()
    {

       if (!$this->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_FULLY')) {
           return $this->redirect($this->generateUrl('_login'));
       }

       $em = $this->getDoctrine()->getManager();

       $subject = $em->getRepository('AppBundle:Subject')->findAll();

       $students = $em->getRepository('AppBundle:User')->findBy(
           array('roles'=>'a:0:{}')
       );

       return $this->render('::gradebook.html.twig', array('students'=>$students),
                                                     array('subjects'=>$subject));
    }
}

Upvotes: 1

Views: 1699

Answers (1)

Ohgodwhy
Ohgodwhy

Reputation: 50787

Combine the two into an array with multiple keys.

return $this->render('::gradebook.html.twig', array('students' => $students, 'subjects' => $subject));

Upvotes: 2

Related Questions