Reputation: 1164
I'm quite busy with working with the Zend_Form object.
I'm building a form which will be used to create new invoices.
As you can see in the above image it's a form with several different input fields on different places on the page and in the HTML code.
Normally you would use decorators to do this but I don't think this is a preferrable situation.
The button which inserts new HTML creates new input fields with the same names but with [NUMBER] at the end(creates arrays).
I think it's the best to just add the fields manually in the view script(Pseudo code: echo Zend_Form_Text_Element->toHtml();..
Can anyone give me advice how to get this to work properly?
Upvotes: 2
Views: 122
Reputation: 5736
You should use the view script decorator. Here is a good link.
Scroll down to the part where it says: Example: Full Customization Using the ViewScript Decorator
Here is a sample form built using the view script:
<h4>Please register with us!</h4>
<form action="<?= $this->escape($this->form->getAction() ?>"
method="<?= $this->escape($this->form->getMethod() ?>">
<fieldset>
<legend>Demographics</legend>
<p>
Please provide us the following information so we can know more about
you.
</p>
<?= $this->form->age ?>
<?= $this->form->nationality ?>
<?= $this->form->income ?>
</fieldset>
<fieldset>
<legend>User Information</legend>
<p>
Now please tell us who you are and how to contact you.
</p>
<?= $this->form->firstname ?>
<?= $this->form->lastname ?>
<?= $this->form->email ?>
<?= $this->form->address1 ?>
<?= $this->form->address2 ?>
<?= $this->form->city ?>
<?= $this->form->state ?>
<?= $this->form->postal ?>
<?= $this->form->phone ?>
</fieldset>
<?= $this->form->submit ?>
</form>
This way u can have full control over the html of the form and u won't need to suffer from the decorators hell :D
Upvotes: 2