By daniboy on
I want my module to provide a form select field where the <option> tags have a class - something along this HTML output:
<select id="edit-location" class="form-select" name="location">
<option selected="selected" value="all">All</option>
<option value="5" class="state">New York</option>
<option value="8" class="city">New York City</option>
<option value="4" class="city">White Plains</option>
<option value="3" class="city">Albany</option>
<option value="1" class="state">New Jersey</option>
<option value="6" class="city">Newark</option>
<option value="2" class="city">Jersey City</option>
<option value="7" class="city">Paterson</option>
</select>
(I don't want to make it a select-group, because I want the user to be able to select either a state or a city)
What is the array that I need to add to the $form to achieve this?
Comments
You may suggest this as a
You may suggest this as a feature request in the Drupal Issues. As this is not an option with the standard FormAPI. The only thing that can be used for '#options' is a keyed array, with the array-key representing the option-value and the array-value representing the option-label.
http://api.drupal.org/api/file/developer/topics/forms_api_reference.html/5
-Craig Jackson
-Web Developer