1. "Fabrik 4" helpers needed!

    You are invited to join other community members active in coding, maintaining and improving Fabrik. Please visit https://fabrik.help for more information!
    Dismiss Notice

Fileupload element notempty validation not working

Discussion in 'Standard Support' started by githinji84, Jan 20, 2017.

  1. githinji84

    githinji84 Member

    Level: Community
    Guys,

    I have a file upload element and I want the user to always attach a file here so I am using the notempy validation plugin on the form but the plugin always fires "This is a required field" even when I have uploaded a file. See attached screen shot.

    Does anyone how to fix this? I am thinking I can also write code using PHP validation plugin but I don't know how to handle files using php (e.g. how to get the file from the form and check if there is anything loaded)

    Please assist.

    Kind regards
    Simon
     
  2. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    Is this a regular upload, or AJAX?

    -- hugh
     
  3. githinji84

    githinji84 Member

    Level: Community
    Hugh,

    This is a regular upload. By "Ajax" you are asking if I have enabled the form to use Ajax. Well the form is not enabled for Ajax.

    Regards
    Simon
     
  4. troester

    troester Well-Known Member Staff Member

    Level: Community
    No, "ajax upload" means the option in the fileupload element settings.
     
  5. githinji84

    githinji84 Member

    Level: Community
    Hi,

    No I have just checked the Ajax option and its not enabled for Ajax i.e. not multiple uploads. See attached screen shot
    Not ajax upload.PNG

    What do think its the issues?

    Regards
    Simon
     
  6. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    The file upload "notempty" validation is a very complex one, and I know we haven't quite gotten it right yet.

    Does it behave the same on:

    A new form, when you don't upload anything.

    An edited form, where there is no already uploaded file, and you aren't uploading one.

    An edited form, where there is an already uploaded file, and you aren't uploading a new one.

    -- hugh
     
  7. githinji84

    githinji84 Member

    Level: Community
    Hugh,

    It behaves different. In the first 2 i.e. new form and edited for but no already loaded file, it fires "This is a required field" whether you have uploaded a file or not. However in the 3rd case of an edited for which has an uploaded file and you are not trying to upload a new one, then this one works okay i.e. does not show "This is a required field" I think because there is an already existing file.

    Does this help?

    Regards
    Simon
     
  8. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    I'll test and get back to you.

    -- hugh
     
  9. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    OK, I can't replicate this.

    Here's a screencast where I create a new form, don't upload, it fails. I add an upload, it works. I edit, and submit again without adding anything, it works.

    The only test case this doesn't show is where an existing form without an already uploaded file is submitting without uploading, but I know that works as well, as I tested it before my last post.

    Are you running relatively a relatively recent version of Fabrik? I did some work on upload validation for 3.5.,1, I think.

    -- hugh
     
  10. githinji84

    githinji84 Member

    Level: Community
    Hugh,

    Thanks. I think you forgot to upload the screen cast. I am also using Fabrik 3.5.1 I don't know why it is not working on my side.

    Have a look at this public form: http://smeboost.com/index.php?option=com_fabrik&view=form&formid=6

    See how the upload field labeled "Upload Company Certificate" is working. If you need admin login details to have a closer look. Let me know

    Kind regards
    Simon
     
  11. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
  12. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    Ah, OK. AJAX validation won't work for file uploads, as the file doesn't actually get uploaded till the form is submitted.

    That's one of the things I'm working on. I'll see if I can work up a solution soon.

    -- hugh
     
  13. githinji84

    githinji84 Member

    Level: Community
    Hugh,

    Thanks for the reply. Let me know how it goes.

    Regards
    Simon
     
  14. githinji84

    githinji84 Member

    Level: Community
    Hugh,

    Nudge...any luck with this query, or it is a bit complicated?

    regards
    Simon
     
  15. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    It's nasty. And I've been swamped with getting the latest build out ... and now having to do a 3.5.3 to fix a couple of issues with 3.5.2.

    -- hugh
     
  16. githinji84

    githinji84 Member

    Level: Community
    Hugh,

    I trust you are well. Did you ever get around fixing the AJAX validation issue on "Notempty" validation for file uploads. See details and your promise. I am getting to a stage that this has become quite important for the functioning of my application.

    Please let me know if you can help me out

    Regards
    Simon
     
  17. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    I don't recall making any promises. I said I'd see if I could work up a solution. I've tried a couple of approaches, I've got a couple more ideas I can try.

    Sent from my HTC6545LVW using Tapatalk
     
  18. githinji84

    githinji84 Member

    Level: Community
    Hugh,

    Yes you did not promise, apologies for that English is not my first language. Thanks for all your assistance so far it has really been helpful. Please let me know if you do crack it.

    Kind regards
    Simon
     
  19. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    OK - I think I may have a way to work round it.

    -- hugh
     

Share This Page