views:

28

answers:

1

Hi,

Zend_Form:: How can be code dublication prevented?When only choosen elements of the form used.

(My restriction: Cant create label with zend_form because i have integrate cushycms- soo i have to write label by hand each time like i show in my code)

The case: need to use in a lot of views same form elements not all of them.

The solution that I see right now is to paste dublication same code in every view that I use only part of Zend_form Elements.

This solution very bad because when i will change the form code I will need to change the code inside every view that use this form.

Do you have better solution?

Example

View 1:

    ................<div>...........
...............
<form  method="<?php $this->escape($this->form->getMethod()); ?>" >

         <label> Title: </label>
         <?php
         echo $this->form->title;
         ?>
        <label>Write Body: </label>
         <?php echo $this->form->body; ?>
      </form>
...................
</div>..................

View 2:

................<div>...........
...............
<form  method="<?php $this->escape($this->form->getMethod()); ?>" >

         <label> Title: </label>
         <?php
         echo $this->form->title;
         ?>
        <label>Write Body: </label>
         <?php echo $this->form->body; ?>
      </form>
...................
</div>..................

View 3: etc....

Thanks

+2  A: 

http://framework.zend.com/manual/en/zend.view.helpers.html

SM
Thanks, I dont understand from zend explanation: 1. how to do validation and filtering to fields 2.How create in controller zend view helper form
Yosef