次のphpを使用して単純な選択要素を追加しようとしているフォームがあります:
$dateFormat = new Zend_Form_Element_Select('dateFormat');
$dateFormat->setLabel('Date Format:');
$dateFormat->setRequired(true)->addValidator('NotEmpty');
$dateFormat->addMultiOptions(array(
'MM/dd/yyyy' => "US Standard - MM/dd/yyyy",
'dd/MM/yyyy' => "Int'l Standard - dd/MM/yyyy",
'MM-dd-yyyy' => "US Standard Dash - MM/dd/yyyy",
'dd-MM-yyyy' => "Int'l Standard Dash - dd/MM/yyyy",
));
$this->addElement($dateFormat,'dateFormat');
ページに問題なくレンダリングされますが、次の XML が生成されます。
<dt id="dateFormat-label"><label for="dateFormat" class="required">Date Format:</label></dt>
<dd id="dateFormat-element">
<select name="dateFormat" id="dateFormat">
<option value="MM/dd/yyyy" label="US Standard - MM/dd/yyyy">US Standard - MM/dd/yyyy</option>
<option value="dd/MM/yyyy" label="Int'l Standard - dd/MM/yyyy">Int'l Standard - dd/MM/yyyy</option>
<option value="MM-dd-yyyy" label="US Standard Dash - MM/dd/yyyy">US Standard Dash - MM/dd/yyyy</option>
<option value="dd-MM-yyyy" label="Int'l Standard Dash - dd/MM/yyyy">Int'l Standard Dash - dd/MM/yyyy</option>
</select></dd>
なぜタグに a..label="..."
を入れるのですか?<option>
これは実際に XHTML 標準で行われるはずの方法ですか? doctype を XHTML Strict に設定しています。