As a follow-up to my last question regarding creating a dynamic select using JavaScript and the Forms API, I'm now wondering how do you actually get the options from that select list in a submit function. I've read "How to get All options of a 'select' field?" but I have yet to get it working with my code. Maybe because this person is using a CCK field and I'm using the Forms API which as far as I've read works differently. I've also tried pulling the data from the $form_state as well as the $form with no luck. Below is my code for a more complete picture of what I'm trying to do:
function _jstest_form($form, &$form_state) {
$form['list'] = array(
'#type' => 'select',
'#options' => array('1', '2', '3'),
'#size' => 4,
);
$form['text'] = array(
'#type' => 'textfield',
);
$form['add_button'] = array (
'#type' => 'button',
'#value' => t("Add"),
'#after_build' => array('_jstest_after_build'),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => 'Submit',
'#submit' => array('_jstest_submit'),
'#after_build' => array('_jstest_after_build'),
);
return $form;
}
function _jstest_submit($form, &$form_state) {
// Do stuff with options from select
}
$form['list']['#options']
, aren't you?