On this page I have an select list with values from a file directory. This works. Only after submitting it doesn't get the value of it. It makes it "1". Normally with a "normal" select list this should work I guess.
Problem: $form_state['input']['edit']['ios_cert'] doesn't return selected value.
Code (in hook_form):
$files = array();
foreach(glob("C:/wamp/www/drupal2/sites/default/files/*.pem") as $filename) {
array_push($files, substr(strrchr($filename, '/'), 1));
}
$form['replace_textfield']['edit']['ios_cert'] = array(
'#title' => t('Select right certificate file'),
'#type' => 'select',
'#options' => $files,
'#default_value' => $ios_key,
'#weight' => 45,
);
Code (hook_submit):
$ios = $form_state['input']['edit']['ios_cert'];
$query = db_update('push_notifications_api')
->fields(array(
'app_id' => $app_id,
'GCM' => $gcm,
'ios' => $ios,
'ios_mode' => $ios_mode,
))
->condition('app_id', $oldid)
->execute();
drupal_set_message(t('@title has been updated succesfully.', array('@title' => $title)));
dsm($form_state);
Result:
And it should be something like "Filename-djfklasjklf.pem"
thanks in advance!