I am using Form api to build one form.In that I have used select type field and for that options are coming from an array. Below is the code
$fnames = array();
$dir_path = variable_get('file_public_path', conf_path(). '/files');
$files1 = scandir($dir_path);
$dirs = glob($dir_path . '/*' , GLOB_ONLYDIR);
foreach($dirs as $directs){
$names = explode('/', $directs);//
$fnames[] = end($names);
}
$form['select_list'] = array(
'#type' => 'select',
'#title' => t('Folder Names'),
'#options' => $fnames,
);
While displaying on the select list it will display all names but when I will fetch the value in one of the submit function it will show only index value not the name.
function custom_submit_file_upload($form, &$form_state){
$foldername = $form_state['values']['select_list'];
}
Here it shows,
$foldername = 0 or 1 or 2 whatever I select in the options,
but I need name of the selected element not the index values. Please suggest me to get the names.Thank you in advance..