我正忙于处理Zend_Form对象。
我正在构建一个表单,该表单将用于创建新发票。

正如您在上图中看到的,它是一个表单,在页面上的不同位置和HTML代码中有几个不同的输入字段。
通常情况下,你会使用装饰器来做这件事,但我不认为这是一个更好的情况。
插入新HTML的按钮创建具有相同名称但末尾为数字的新输入字段(创建数组)。
我认为最好是在视图脚本中手动添加字段(伪代码: echo Zend_Form_Text_Element->toHtml();..
有没有人能给我一些建议,让它正常工作?
发布于 2012-05-21 22:34:30
您应该使用视图脚本装饰器。这是一个很好的link。
向下滚动到显示以下内容的部分:Example: Full Customization Using ViewScript Decorator
以下是使用视图脚本构建的示例表单:
<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>这样,您就可以完全控制表单的html,而不需要忍受装饰者的地狱:D
https://stackoverflow.com/questions/10686739
复制相似问题