Hello,

I am trying to understand the best recommend way to implement a form using 
Zend_Form. There seem to be a number of different ways in implementing and 
rendering them.

Here is my situation:

We are developing an application and will be using a number of ZF components: 
_DB, _Auth, _ACL, _View, _Layout, _Controller, etc...  as well as _Form.

When we want to built and show a form, we call a model like: TestingForm.php 
from TestingController.php 

The TestingController.php has a method:
getTestingForm() {
   $this->_myform = new TestingForm(array('action'=>testing/process', 
'method'=>'post'));
}


The TestingForm.php is built as such:
TestForm extends Zend_Form {
   public function __construct($options=null) {
          parent::__construct($options);

     $this->setAttrib('accept-charset', 'UTF-8');
}


   public function init() {
     $name = $this->addElement('text', 'name', array().....);
}

}




So now on my display page with the form, I have an action 
indexAction() {
     $this->view->testform = $this->getTestingForm();
}

and the view is:
<?php echo $this->testform; ?>


=================

Is this recommened?



2)  I want to be able to add elements dynamically to the form depending on a 
result set of data from the db.

Say a person has 4 children, I want to dynamically add four text elements to 
the form, one for each record retrieved from the db.

How can I do this with my setup?

Any suggestions or advice would be great.

Thank you.







      

Reply via email to