Reputation: 73
Hello guys let me explain:
$this->view->form = new Application_Form_Kursdaty();
$url = $this->view->url(
array(
'action' => 'details',
'controller' => $this->getRequest()->getControllerName(),
'module' => $this->getRequest()->getModuleName(),
'id' => @@@@@SELECTFIELD[selected]@@@@@@
),
'default',
true
);
$this->view->form->setAction($url);
I basically want my select field to redirect to page which i choose. I dont really know what to do, please help!
Upvotes: 1
Views: 85
Reputation: 8519
Here's your problem!
The value of the select element is not set until after the submit button is pressed. So you don't have access to the value until after the post.
So a way to do what you want to do in PHP would be to use 2 actions. The first action takes the post and performs the validation then you could take the data and forward it to the action of your choice depending on the value of that select.
public function formAction() {
$form = new Form();
$form->setAction('/url');
if ($this->_request->isPost()){
if ($form->isValid($this->_request->getPost()){
$select = $form->getValue('select');
switch($select) {
case ('value1') :
$this->_forward('action');
break;
case ('value2') :
$this->_forward('action');
break;
default :
$this->_forward('action');
}
}
} else {
$this->view->form = $form
}
This might be the kind of work flow you would look at for the first action. You'll need to work out the details but a _forward
should be doable in this instance as it should perform the redirect without losing the current request object.
Upvotes: 1
Reputation: 3503
If your form is instance of Zend_Form
and populated with sent data then you can use $form->getValue($nameOfField)
or $form->getElement($elementName)->getValue()
Upvotes: 1