我正在使用Xml配置创建Zend_Form,它定义了两个元素select和multiheckbox。我发现这个link回答了我的一个问题,但我找不到任何multiheckbox元素语法的例子。
感谢任何帮助。
这是我到目前为止所做的事情(为了好玩)
<?xml version="1.0" encoding="UTF-8"?>
<form>
<localhost>
<formmanager>
<pizza>
<action>/form/</action>
<method>post</method>
<name>Pizza</name>
<elements>
<crust>
<type>Select</type>
<name>crust</name>
<options>
<label>Crust:</label>
<required>true</required>
<multioptions>
<option value="Thin crust">Thin crust</option>
<option value="Thick crust">Thick crust</option>
</multioptions>
</options>
</crust>
<pan>
<type>MultiCheckbox</type>
<required>true</required>
<options>
<label>Pan:</label>
<multioptions>
<option>American Hot</option>
<option>Cheese and tomato</option>
</multioptions>
</options>
</pan>
</elements>
</pizza>
</formmanager>
</localhost>
</form>
答案 0 :(得分:4)
解决方案:经过很长一段时间,查看Zend_Config,Zend_Config_Xml,Zend_Form_Element_MultiChoiceBox和Zend_Form_Element_Multi类,我想出来了,这里是
<?xml version="1.0" encoding="UTF-8"?>
<form>
<localhost>
<formmanager>
<pizza>
<action>/form/</action>
<method>post</method>
<name>Pizza</name>
<elements>
<crust>
<type>Select</type>
<name>crust</name>
<options>
<label>Crust:</label>
<required>true</required>
<multioptions>
<thin_crust>Thin Crust</thin_crust>
<thick_crust>Thick Crust</thick_crust>
</multioptions>
<value>test</value>
</options>
</crust>
<pan>
<type>MultiCheckbox</type>
<name>pan</name>
<options>
<label>Pan:</label>
<multioptions>
<american>American Hot</american>
<cheese>Cheese and Tomato</cheese>
</multioptions>
<required>true</required>
</options>
</pan>
</elements>
</pizza>
</formmanager>
</localhost>
</form>