This is a followup question regarding an API question I had.
I am using Zend Framework 2.
zf-skeleton/module/MyApplication/src/MyApplication/Controller/IndexController.php
public function submitAction() {
$myForm = new MyForm();
$myForm->get('submit')->setValue('Add');
$request = $this->getRequest();
if ($request->isPost()) {
$myModel = new MyModel();
$myForm->setInputFilter($myModel->getInputFilter());
$myForm->setData($request->getPost());
if ($myForm->isValid()) {
// Form is validated. [1]
Now the form is validated, do I send the POST
arguments to another action within this controller or create a new controller?
I am looking for best practices.
As for best practices, In a small scale application , it would be unwise to create a new controller. But when we talk about a large scale application, each piece is done seperately, and new controller is recommended. So, it totally depends on your application.
never use controller inside a controller. if you want to share a common method in multiple controllers you must create a component(for cakephp framework) or a controller plugin (for zend). visit http://lab.empirio.no/custom-controller-plugin-in-zf2.html