Skip to main content
made clear the values shown are an example (comment edited Aug 1, 2016 at 5:49)
Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

Since the form submission handler has access to the $form variable, you just use the following code.

$foldername = $form['select_list']['#options'][$form_state['values']['select_list']];

To make it clear with an example: $form['select_list']['#options'] is an array like array( 1 => 'first folder', 2 => 'second folder'), and $form_state['values']['select_list'] is a value between 1 and 2.

Since the form submission handler has access to the $form variable, you just use the following code.

$foldername = $form['select_list']['#options'][$form_state['values']['select_list']];

To make it clear: $form['select_list']['#options'] is an array like array( 1 => 'first folder', 2 => 'second folder'), and $form_state['values']['select_list'] is a value between 1 and 2.

Since the form submission handler has access to the $form variable, you just use the following code.

$foldername = $form['select_list']['#options'][$form_state['values']['select_list']];

To make it clear with an example: $form['select_list']['#options'] is an array like array( 1 => 'first folder', 2 => 'second folder'), and $form_state['values']['select_list'] is a value between 1 and 2.

Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

Since the form submission handler has access to the $form variable, you just use the following code.

$foldername = $form['select_list']['#options'][$form_state['values']['select_list']];

To make it clear: $form['select_list']['#options'] is an array like array( 1 => 'first folder', 2 => 'second folder'), and $form_state['values']['select_list'] is a value between 1 and 2.