如何设置 zend 表单的样式和格式?

发布于 2024-12-17 14:48:56 字数 1702 浏览 3 评论 0原文

我想知道如何设计 zend 表单的样式:

// Pants
    $this->addElement('select', 'waistmin', array(
            'label' => 'Pants: ',
            'multiOptions' => array_merge(array(''=>'', 'Any'=>'Any'),array_combine(range(21, 48), range(21, 48)) ),
            'value' => 'Any'
    ));

    $this->addElement('select', 'waistmax', array(
            'label' => 'to: ',
            'multiOptions' => array_merge(array(''=>'', 'Any'=>'Any'),array_combine(range(21, 48), range(21, 48)) ),
            'value' => 'Any'
    ));

    // Bust & Chest
    $this->addElement('select', 'bustmin', array(
            'label' => 'Bust & Chest: ',
            'multiOptions' => array_merge(array(''=>'', 'Any'=>'Any'),array_combine(range(30, 50), range(30, 50)) ),
            'value' => 'Any'
    ));

    $this->addElement('select', 'bustmax', array(
            'label' => 'to: ',
            'multiOptions' => array_merge(array(''=>'', 'Any'=>'Any'),array_combine(range(30, 50), range(30, 50)) ),
            'value' => 'Any'
    ));

我在 form.php 中有此表单,并使用 echo $this->form; 放入我的视图文件中,

我知道我可以添加style 标签和 id 标签,但我想要的是这样更好地定位它们。

现在它们一个接一个地出现:

Pants:
   <drip down>
to:
   <drip down>
Bust & Chest:
   <drip down>
to:
   <drip down>

我想将它们分组在 div 中或者可能在表格中:

Pants:               to:
   <drip down>           <drip down>

Bust & Chest:               to:
   <drip down>           <drip down>

如果我在表单中回显 html,它将不会在我的页面中呈现。

关于我可以采取什么方法有什么想法吗?

谢谢

i was wondering how to style a zend form:

// Pants
    $this->addElement('select', 'waistmin', array(
            'label' => 'Pants: ',
            'multiOptions' => array_merge(array(''=>'', 'Any'=>'Any'),array_combine(range(21, 48), range(21, 48)) ),
            'value' => 'Any'
    ));

    $this->addElement('select', 'waistmax', array(
            'label' => 'to: ',
            'multiOptions' => array_merge(array(''=>'', 'Any'=>'Any'),array_combine(range(21, 48), range(21, 48)) ),
            'value' => 'Any'
    ));

    // Bust & Chest
    $this->addElement('select', 'bustmin', array(
            'label' => 'Bust & Chest: ',
            'multiOptions' => array_merge(array(''=>'', 'Any'=>'Any'),array_combine(range(30, 50), range(30, 50)) ),
            'value' => 'Any'
    ));

    $this->addElement('select', 'bustmax', array(
            'label' => 'to: ',
            'multiOptions' => array_merge(array(''=>'', 'Any'=>'Any'),array_combine(range(30, 50), range(30, 50)) ),
            'value' => 'Any'
    ));

i have this form in a form.php and i place in in my view file by using echo $this->form;

i know that i can add style tags and id tags, but what i want it so position them better.

right now they come one after each other:

Pants:
   <drip down>
to:
   <drip down>
Bust & Chest:
   <drip down>
to:
   <drip down>

i want to group the together in divs or maybe in a table:

Pants:               to:
   <drip down>           <drip down>

Bust & Chest:               to:
   <drip down>           <drip down>

if i echo html inside the form it will not render inside my page.

any ideas on what approach i can take?

thans

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

眼藏柔 2024-12-24 14:48:56

如果您想更好地控制各个表单元素的显示方式和位置,您可以输出各个表单元素并将它们包装在您认为合适的 html 中。

请参阅此处的答案。这个关于 拆分 zend 表单的答案可能会对您有所帮助它展示了如何从 select 元素中删除装饰器,这样它就不会被包装在任何 html 中,这将与下面的示例配合良好。

您可以执行以下操作,而不是执行 echo $this->form; 操作:

<div class="form-sel">
Pants: <?php echo $this->form->waistmin ?> to: <?php echo $this->form->waistmax ?>
</div>

<div class="form-sel">
Bust & Chest: <?php echo $this->form->bustmin ?> to: <?php echo $this->form->bustmax ?>
</div>

If you want to have more control over how and where individual form elements are displayed, you can output individual form elements and wrap them in html as you see fit.

See the answer here. This answer on splitting up a zend form may help you as well as it shows how to remove decorators from the select element so it isn't wrapped in any html which will work well with the example below.

Instead of doing echo $this->form; you can do something like the following:

<div class="form-sel">
Pants: <?php echo $this->form->waistmin ?> to: <?php echo $this->form->waistmax ?>
</div>

<div class="form-sel">
Bust & Chest: <?php echo $this->form->bustmin ?> to: <?php echo $this->form->bustmax ?>
</div>
帅气尐潴 2024-12-24 14:48:56

根据 zend 文档,您应该使用装饰器来更改表​​单元素的标记,也可以尝试 $form->render() insetad echo。
http://framework.zend.com/manual/en/zend.form .standardDecorators.html

Аccording zend documentation you should use decorators to change markup of your form elements, also try $form->render() insetad echo.
http://framework.zend.com/manual/en/zend.form.standardDecorators.html

蓝眼泪 2024-12-24 14:48:56

为什么不简单地为 dl、dt 和 dd Zend Forms 使用 CSS。这将允许您修改他们的样式

Why dont you simply do CSS for the dl, dt and dd Zend Forms use. That will allow you to modify their styling

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文