Optgroup in drupal 7 list field
you can use a hook_FORM_ID_alter and then add code like this:

$form['FIELDNAME']['#options'] = array (

   'parent1' =&gt; array(
      3 =&gt; 'child1',
      4 =&gt; 'child2',
      5 =&gt; 'child3',
    ),
    'parent2' =&gt; array(
      8 =&gt; 'child1',
      9 =&gt; 'child2',
    ),
);