当表单本身由ini文件构造时,如何在Zend_Form(1.x)中指定optgroup?
我想列出一些按国家“分组”的机场
France
- Paris
Germany
- Munich
- Hamburg
Spain
- Madrid
- Barcelona
INI:
elements.airports.type = "select"
elements.airports.options.label = "Airport:"
elements.airports.options.multiOptions... ???
答案 0 :(得分:1)
检查类Zend_Form_Element_Multi,在isValid方法中,它提到了optgroup。
foreach ($multiOptions as $opt_value => $opt_label) {
// optgroup instead of option label
if (is_array($opt_label)) {
$options = array_merge($options, array_keys($opt_label));
}
...
因此,optGroups是一个选项数组。在您的示例中:
elements.airports.options.multiOptions.optGroupName.optionValue = "optionText"
elements.airports.options.multiOptions.France.PA = Paris
elements.airports.options.multiOptions.Germany.MU = Munich
elements.airports.options.multiOptions.Germany.HA = Hamburg