2

I have created a form and I am trying to get an image to upload. I have the following set:

$this->add(
      'file', // field type
      'image_file', // field name
      'Upload Image', // field label      
      TRUE // is required
    );

However, when I submit the file it does not upload anywhere. Any ideas on what I am doing wrong?

Thanks!

2

You missed a param to that function. The 4th param is attributes, which you can pass as an empty array, and the 5th param is required, which you can pass TRUE.

| improve this answer | |
  • I added the array and it now gives me the following error when submitting: "Please correct the following errors in the form fields below: Upload Image is a required field." – Sleewok Jan 19 '17 at 14:56
  • ALSO, where can I find documentation on the attributes? I would like to specify the filename when uploading... – Sleewok Jan 19 '17 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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