ZendFramework - 如何使用视图助手创建 optgroup 和 there 选项? [英] ZendFramework - How to create optgroup and there option using view helpers?

查看:14
本文介绍了ZendFramework - 如何使用视图助手创建 optgroup 和 there 选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何使用 $this->formSelect() 创建它?

How do i create this with $this->formSelect() ?

<select multiple>
    <optgroup label="a">
       <option>1</option> 
       <option>2</option>
    </optgroup>
    <optgroup label="b">
       <option>1</option> 
    </optgroup>
</select>

推荐答案

对于 Zend_Form_Element_Select() 是这样的

For the Zend_Form_Element_Select() it goes like this

$multiOptions = array(
  'Group A' => array(1 => 'First Value',2 => 'Second Value A),
  'Group B' => array(3 => 'Third Value'),
);

$element->setMultiOptions($multiOptions);

请注意,您还有 addMultiOption($option,$value) 和 addMultiOptions($options).只需在附加数组中包含值或选项.

Note that you also have addMultiOption($option,$value) and addMultiOptions($options). Simply include the value or options in an additional array.

这篇关于ZendFramework - 如何使用视图助手创建 optgroup 和 there 选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆