tags:

views:

164

answers:

1

I need to use the selected value of a select list when the form is submitted (in submit handler). I am familiar with using the Form API, but can't find the solution on drupal.org.

For example, I am loading a select list with 3 options. When the user selects a value and submits. I want to grab that value and use it in an SQL query that I have located in my submit handler.

$form['my_select'] = array('#type = 'select',
                           '#title' = 'Pick a value',
                           '#options' = array('dog' => 'Choice One', 
                                              'cat' => 'Choice two',
                                              'bird'=> 'Choice three'),
                          );

Then I want to use the value the user selected in a custom submit handler.

A: 

Finally got this to work:

$form_state['values']['my_select'] = array('0' => array('value' => $form['my_select']['#value'])
cinqoTimo