1.

How can you pass data from the controller to view in Phalcon?

Answer»

You can use setVar() or setVars() in the CONTROLLER’s showAction() method to PASS SINGLE or multiple variables respectively, DIRECTLY to the view.

  • $this->view->setVar('productId', $productId);
  • $this->view->setVars( ['username' => $user->username, 'PHONE' => $contact->phone,] );

Instead of using the above methods, you can also set the variables as $this->view->username = $user->username;



Discussion

No Comment Found