首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Zend_Form高级用法(阵列)

Zend_Form高级用法(阵列)
EN

Stack Overflow用户
提问于 2012-05-21 22:02:30
回答 1查看 111关注 0票数 2

我正忙于处理Zend_Form对象。

我正在构建一个表单,该表单将用于创建新发票。

正如您在上图中看到的,它是一个表单,在页面上的不同位置和HTML代码中有几个不同的输入字段。

通常情况下,你会使用装饰器来做这件事,但我不认为这是一个更好的情况。

插入新HTML的按钮创建具有相同名称但末尾为数字的新输入字段(创建数组)。

我认为最好是在视图脚本中手动添加字段(伪代码: echo Zend_Form_Text_Element->toHtml();..

有没有人能给我一些建议,让它正常工作?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-05-21 22:34:30

您应该使用视图脚本装饰器。这是一个很好的link

向下滚动到显示以下内容的部分:Example: Full Customization Using ViewScript Decorator

以下是使用视图脚本构建的示例表单:

代码语言:javascript
复制
<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

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10686739

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档