views:

55

answers:

4

Can I use my normal (html) form in Zend Framework ? How can I do that & How can I call action in IndexController file?

+1  A: 

of course you can ... just use

<form action="/index/action" methode="POST">

to access post arguments use

$this->getRequest()->getParam('argument')
roman
Yes! I tried. This is working fine.Thanx!
Sadee
A: 

Yes, I have a module called 'contact', and an action addcontactAction() in the ContactController.php.

So I can use : /view/scripts/contacts/addcontact.phtml

<form  action="" method="post" name="frm_addcontact" />
<input name="cn_fname" type="text" class="textbox" id="cn_fname"/>
<input type="submit" class="button" id="save" value="Save" />
</form>

when this form is submitted, it calls addcontactAction() in the controller.

$cn_fname       = $_REQUEST['cn_fname']; 
Sadee
+1  A: 

Hi,

thats no problem, put your form code inside the view script for the associated action. Maybe:

formAction() 
{
   // check if post request
   if ($this->getRequest()->isPost()) {       
       // read global $_POST array
       $data = $this->getRequest()->getPost();
   }
}

the associated view ist than form.phtml

ArneRie
+1  A: 

Yes, definitely.. You just have to remove the isValid call in your controller since it won't be performing any validation and also remove the post request check if it will not contain any form. It's like creating a common view with simple links in it.

Hanseh