Form input returns "1" instead of real value 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' =&gt; t('Select right certificate file'),
    '#type' =&gt; 'select',
    '#options' =&gt; $files,
    '#default_value' =&gt; $ios_key,
    '#weight' =&gt; 45,
  );


Code (hook_submit):

$ios = $form_state['input']['edit']['ios_cert'];

$query = db_update('push_notifications_api')
-&gt;fields(array(
'app_id' =&gt; $app_id,
'GCM' =&gt; $gcm,
'ios' =&gt; $ios,
'ios_mode' =&gt; $ios_mode,
))
-&gt;condition('app_id', $oldid)
-&gt;execute();
drupal_set_message(t('@title has been updated succesfully.', array('@title' =&gt; $title))); 
dsm($form_state);


Result:



And it should be something like "Filename-djfklasjklf.pem"

thanks in advance!
I already got it.

I added this:

foreach ($files as $record){
    $options1[$record] = $record;
 }


And then use $options1 as '#options'