I have controller Index:

class IndexController extends Zend_Controller_Action
{
    public function oneAction()
    {
        $oneForm = new Application_Form_One();
        $oneForm->setAction('/index/one');

        if ($this->getRequest()->isPost()) {
            if ($oneForm->isValid($this->getRequest()->getPost())) {
                // saving ...
                // 
                $this->_redirect('/index/list/');
            }
        }

        $this->view->oneForm = $oneForm;
    }

    public function twoAction()
    {
        $twoForm = new Application_Form_Two();
        $twoForm->setAction('/index/two');

        if ($this->getRequest()->isPost()) {
            if ($twoForm->isValid($this->getRequest()->getPost())) {
                // saving ...
                // 
                $this->_redirect('/index/list/');
            }
        }

        $this->view->twoForm = $twoForm;
    }

    public function threeAction()
    {
        $threeForm = new Application_Form_Three();
        $threeForm->setAction('/index/three');

        if ($this->getRequest()->isPost()) {
            if ($threeForm->isValid($this->getRequest()->getPost())) {
                // saving ...
                // 
                $this->_redirect('/index/list/');
            } else {
                //return $this->_forward('page');
            }
        }

        $this->view->threeForm = $threeForm;
    }

    public function pageAction()
    {
//        $oneForm = new Application_Form_One();
//        $oneForm->setAction('/index/one');
//
//        $twoForm = new Application_Form_Two();
//        $twoForm->setAction('/index/two');
//
//        $threeForm = new Application_Form_Three();
//        $threeForm->setAction('/index/three');
//
//        $this->view->oneForm = $oneForm;
//        $this->view->twoForm = $twoForm;
//        $this->view->threeForm = $threeForm;
        
        $this->_helper->actionStack('three');
        $this->_helper->actionStack('two');
        $this->_helper->actionStack('one');
    }

    public function listAction()
    {
        // action body
    }
}

Code of the One form
class Application_Form_One extends Zend_Form
{
    public function init()
    {
        $this->addElement('text', 'element1', array(
            'label' => 'Element 1 one',
            'required' => true,
            'belongsTo' => 'one',
        ));
        
        $this->addElement('text', 'element2', array(
            'label' => 'Element 2 one',
            'required' => true,
            'belongsTo' => 'one',
        ));
        
        $this->addElement('submit', 'submit', array(
            'label' => 'Submit one',
            'required' => false,
            'ignore' => true,
            'belongsTo' => 'one',
        ));
    }
}

Code of the Two form
class Application_Form_Two extends Zend_Form
{

    public function init()
    {
        $this->addElement('text', 'element1', array(
            'label' => 'Element 1 two',
            'required' => true,
            'belongsTo' => 'two',
        ));
        
        $this->addElement('text', 'element2', array(
            'label' => 'Element 2 two',
            'required' => true,
            'belongsTo' => 'two',
        ));
        
        $this->addElement('submit', 'submit', array(
            'label' => 'Submit two',
            'required' => false,
            'ignore' => true,
            'belongsTo' => 'two',
        ));
    }
}

Code of the Three form:
class Application_Form_Three extends Zend_Form
{

    public function init()
    {
        $this->addElement('text', 'element1', array(
            'label' => 'Element 1 three',
            'required' => true,
            'belongsTo' => 'three',
        ));
        
        $this->addElement('text', 'element2', array(
            'label' => 'Element 2 three',
            'required' => true,
            'belongsTo' => 'three',
        ));
        
        $this->addElement('submit', 'submit', array(
            'label' => 'Submit three',
            'required' => false,
            'ignore' => true,
            'belongsTo' => 'three',
        ));
    }
}

How to implement pageAction to that he output three of these forms and in
the validation of any of them and if it is not valid then also Display some
two forms?


--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Several-form-on-one-page-tp3649452p3649452.html
Sent from the Zend Framework mailing list archive at Nabble.com.

-- 
List: fw-general@lists.zend.com
Info: http://framework.zend.com/archives
Unsubscribe: fw-general-unsubscr...@lists.zend.com


Reply via email to