Use the same form class ;). You have to remember that a Zend_Form is a 
programmatic description of the form structure, validation rules, filtering 
rules, with a sprinkling of customisation via attribute additions. Every form 
upon instantiation from the same class is identical. What differentiates them 
is the data they are given. In this case - that's $_POST. So it's a matter of 
ensuring that the data (passed via isValid()) in both functions is the same, or 
rather part of the same input workflow. Both function would simply instantiate 
the same form class since the forms for both, other than data, are the same.

Make sense?

Paddy

 Pádraic Brady

http://blog.astrumfutura.com
http://www.patternsforphp.com
OpenID Europe Foundation




----- Original Message ----
From: Bagus Nugroho <[EMAIL PROTECTED]>
To: [email protected]
Sent: Thursday, May 22, 2008 5:07:59 AM
Subject: [fw-general] Zend_Form Form and Action on different function


Hi,
 
How to make validation if form and action on different function, 
==============================================
class FooController extends Zend_Controller_Action{
public function barAction(){
 /**
  function will be defined here
  but action wil be on processAction()
 */
  $form = new My_Form();
  $form->setAction('process');
 
  /** on same function
   if($form->isValid($_POST)){
  */
}
 
public function processAction(){
   /**
    check if the data is valid
   */
   if($????->isValid($_POST)){
      echo 'data inserted';
    }
   }
}
=======================================
 
How we can get form that have been submitted?
 
Thanks in advance
bn

Reply via email to