如何设置 zend 表单的样式和格式?
我想知道如何设计 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您想更好地控制各个表单元素的显示方式和位置,您可以输出各个表单元素并将它们包装在您认为合适的 html 中。
请参阅此处的答案。这个关于 拆分 zend 表单的答案可能会对您有所帮助它展示了如何从 select 元素中删除装饰器,这样它就不会被包装在任何 html 中,这将与下面的示例配合良好。
您可以执行以下操作,而不是执行
echo $this->form;
操作: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:根据 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
为什么不简单地为 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