J'ai une forme que je suis en train d'ajouter un élément de sélection simple à l'aide du php suivant:Zend Framework: Zend Form Sélectionnez Générer verbeux HTML en utilisant MultiOptions
$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');
Il rend à la page très bien, mais il génère le code XML suivant:
<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>
Pourquoi est-il mettre un ..label="..."
dans la balise <option>
? Est-ce réellement la façon dont il est censé être fait pour les normes XHTML? J'ai mon doctype défini sur XHTML Strict.