OK, maybe it wasn't exactly what I was looking for.
Now I have another problem. I made somehing like this:

public function addAction()
    { 
        $this->view->title = "Add Request";
        $this->view->headTitle($this->view->title, 'PREPEND');
        
        $form = new Form_Add();
        //$this->view->form = $form;
        
        if ($this->getRequest()->isPost()) {
            $formData = $this->_request->getPost();
            if ($form->isValid($formData)) {
                $reqName = $form->getValue('requestName');
                $type    = $form->getValue('type');
                $request = $form->getValue('request');
                $requests = new Model_DbTable_Requests();
                $requests->addRequest($reqName, $type, $request);
            }
            $this->_forward('critere'); 
        }
        
        $this->view->form = $form;
    }
    
    public function critereAction()
    {
         $this->view->title = "Add critere";
        $this->view->headTitle($this->view->title, 'PREPEND');
        
        $form = new Form_Add();
//        $this->view->form = $form;
        
        if ($this->getRequest()->isPost()) {
            $formData = $this->_request->getPost();
            if ($form->isValid($formData)) {
                $reqName = $form->getValue('requestName');
                $type    = $form->getValue('type');
                $request = $form->getValue('request');
                $requests = new Model_DbTable_Requests();
                $requests->addRequest($reqName, $type, $request);
            }
            //$this->_forward('index'); 
        }
        
        $this->view->form = $form;
        
    }

I know it looks stupid, cause it's the same code in both actions.
The problem is that when I'm going from index to add action, my add form
waits till I put some data into the form elements and than to click submit.
When I do that it goes to critere action, where it adds the same data right
away without waiting for submit. WHY????
I've made the same actions just to be sure, that i didn't make any syntax
error. But i also tried whith other code in critere action and it was the
same, the critere was transparent.




magrytos1 wrote:
> 
> This is exactly what I was looking for.
> thank you
> 
> 
> Bart McLeod wrote:
>> 
>> are you looking for $this->_forward('critere'); after your submit action 
>> has completed?
>> 
>> -Bart
>> 
>> magrytos1 schreef:
>>> Hi.
>>>
>>> I have action add and a form for this action. After click on submit
>>> button i
>>> want to add a data that I chose to my database and also I want to go to
>>> the
>>> next page of my form 'critere'. When i put 
>>>
>>> setAction('critere');
>>>
>>> in my form add  form, after pushing submit button it goes to form
>>> critere,
>>> but it doesn't add any data to my db. If I comment setAction() function,
>>> it
>>> adds data, but it stays in add form. 
>>> Is it possible to put an array as an arguments for setAction()? If not,
>>> how
>>> can I do 2 actions by pushin one button.
>>>
>>> public function addAction()
>>>     { 
>>>         $this->view->title = "Add Request";
>>>         $this->view->headTitle($this->view->title, 'PREPEND');
>>>         
>>>         $form = new Form_Add();
>>>         //$this->view->form = $form;
>>>         
>>>         if ($this->getRequest()->isPost()) {
>>>             $formData = $this->_request->getPost();
>>>             if ($form->isValid($formData)) {
>>>                 $reqName = $form->getValue('requestName');
>>>                 $type = $form->getValue('type');
>>>                 $request = $form->getValue('request');
>>>                 $requests = new Model_DbTable_Requests();
>>>                 $requests->addRequest($reqName, $type, $request);
>>>             }
>>>         }
>>>         
>>>         $this->view->form = $form;
>>>     }
>>>
>>> thx
>>>   
>> 
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Zend-Form---setAction%28%29-tp24424644p24429437.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to