Zend_Form ::当只使用所选表单的元素时,如何防止代码重复?

时间:2010-07-05 23:11:56

标签: zend-framework zend-form

Zend_Form ::如何阻止代码发布?当只选择使用的表单元素时。

(我的限制:不能用zend_form创建标签,因为我已整合了cushycms- soo我必须每次手工编写标签,就像我在我的代码中显示一样)

案例:需要在很多视图中使用相同的表单元素而不是全部。

我现在看到的解决方案是在每个只使用部分Zend_form Elements的视图中粘贴 dublication 相同的代码。

这个解决方案非常糟糕,因为当我更改表单代码时,我需要更改使用此表单的每个视图中的代码。

你有更好的解决方案吗?

实施例

查看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>..................

查看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>..................

查看3:等等....

由于