How to add separator option in Form API 'select' element? Is there a way with the Form API to specify that one or more #options in a 'select' element should be disabled? I would like to insert a separator in my dropdown options that is not a selectable value.
If it's really a separator you're looking to add then it might make more semantic sense to use &lt;optgroup&gt;s to group your select options.

You can do this with the form API simply by wrapping each group you want in the &lt;select&gt; in an array, keyed by the title you want for the label:

$form['test'] = array(
  '#type' =&gt; 'select',
  '#title' =&gt; 'test',
  '#weight' =&gt; -10000,
  '#options' =&gt; array(
    'Group 1' =&gt; array(
      1 =&gt; 'Group 1 Item 1'
    ),
    'Group 2' =&gt; array(
      2 =&gt; 'Group 2 Item 1',
      3 =&gt; 'Group 2 Item 2'
    )
  )
);


That will produce a select list like this: