1

I have a form field such as ,

   $form['fileTransfer_settings']['file_path'] = array(
    '#type' => 'file',
    '#title' => t('Choose file'),
    '#size' => 22,
    '#description'   => t('path for the csv file'), 

  );

Now I am looking to save the path of the uploaded file in the submit handler ,

But when I look into the value of the form field in the submit handler I get null,

function transferfile_submit_handler($form, &$form_state) {

     dpm($form_state[values]); //other fields show value 
     dpm($form_state['values']['fileTransfer_settings']['file_path']); //null
 }

What am I doing wrong here?

1 Answer 1

1

Submitted values are flattened unless the form element contains the #tree property.

So either use:

$form_state['values']['file_path'];

Or change the wrapper:

$form['fileTransfer_settings'] = array(
  '#tree' => TRUE,
  ...
);

And use your current submission code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.