I have a select field for a content type which has options generated dynamically. The options are updated in hook_form_alter(). The problem is that when I try to manipulate the posted data in submit callback, the field values are empty. Below is an example to better understand the issue.
function my_form_alter(&$form, &$form_state) {
$options = array('a' => 1, 'b' => 2, 'c' => 3);
$form['my_field'] = array(
'#type' => 'select',
'#title' => t('Label'),
'#multiple' => TRUE,
'#options' => $options,
'#default_value' => '',
);
$form['#submit'][] = 'my_submit_handler';
}
function my_submit_handler($form) {
echo "<pre>";
var_dump($form['my_field']);
echo "</pre>";
}
If I select options 2 and 3 for example; the var_dump returns empty array().