By CZ on
How can I add the option elements a class?
Goal:
<select>
<option class="green">Yes</option>
<option class="red">No</option>
</select>
This code add a class to the select element:
function test_form() {
$form['test_form'] = array(
'#type' => 'select',
'#default_value' => variable_get('test_form', 0),
'#options' => array(
'yes' => t('Yes'),
'no' => t('No'),
),
'#attributes' => array('class' => 'orange'),
}
Like http://drupal.org/node/229212 but for
Comments
Check this
Check this one
http://drupal.org/node/37862
#attributes should do the trick
'#attributes' => array('class' => 'form-autocomplete'),Try adding that to your form.