How to create multi select list programmatically How to create a multi select list in a custom module, populate values from taxonomy term and access the selected values when the form is submitted.

I have to code below for multi select list. I want to know how to access the multiple selected values from multi select list when the form is submitted.

function rice_graph_form($form, &amp;$form_state) {
  $form['country'] = array(
  '#title' =&gt; t('Country'),
  '#type' =&gt; 'select',
  '#multiple' =&gt; true,
  //'#description' =&gt; 'Select a Country.',
  '#options' =&gt; rice_graph_get_terms('country')
  );
  if(isset($form_state['values'])) {
    $multivalues = $form_state['values']['country'];
  }
}
In your submit handler add something like this:

$selected_countries = array_filter($form_state['values']['country']);


$selected_countries will contain the array keys of all the selected items in your Country select list. You need the array_filter to get rid of unselected items, which also come through to the submit handler but with a value of 0.