ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Validate uploads aren't empty in Safecracker File fieldtype in Safecarcker form

December 29, 2011 11:56am

Subscribe [0]
  • #1 / Dec 29, 2011 11:56am

    Ryan M.

    1511 posts

    We have a Safecracker form where we allow people to post a couple things (PDF, JPG) via Safecracker File fields. I’m adding a number of rules to my SC form, per these instructions: CodeIgniter Form Validation Rule Reference. Here are my rules:

    rules:description="required"
    rules:email="required|valid_email"
    rules:first_name="required"
    rules:last_name="required"
    rules:pdf_attachment="required"
    rules:screenshot="required"

    PDF Attachment and Screenshot are SC File fields. When I submit the form without filling anything out (and with no JS validation), I get all the errors I’d expect:

    The form you submitted contained the following errors
    - The Description field is required.
    - The Your Email field is required.
    - The First Name field is required.
    - The Last Name field is required.
    - The Title field is required.

    There is never anything about the file fields being required. Is it possible to at least make sure something has been entered in that field? If a user disables JS they would be able to submit this form without uploading a single file. I don’t know how else to validate a file upload with this fieldtype on the server side.

    EDIT: This is related to this thread: http://ellislab.com/forums/viewthread/202377/ and a bug report is already in: https://support.ellislab.com/bugs/detail/16798 (as of this writing the bug is over 2 months old and hasn’t been assigned to anyone)

  • #2 / Dec 30, 2011 4:35am

    John Henry Donovan

    12339 posts

    Hi Ryan,

    According to your bug report comment you are running EE2.2.2
    Can you at least install the latest version locally and test. In the meantime I will ping the devs on that bug report

  • #3 / Dec 30, 2011 11:59am

    Ryan M.

    1511 posts

    That’s easier said than done! For now, I just made the fields required in the CP, which makes the required field work on the front end.

  • #4 / Dec 30, 2011 5:03pm

    Dan Decker

    7338 posts

    Hi Ryan,

    Since you have your workaround for the time being, is there anything else we can do for you?

    Cheers!

  • #5 / Dec 30, 2011 11:45pm

    Ryan M.

    1511 posts

    We’re good here with the workaround. Thanks!

  • #6 / Jan 02, 2012 5:20am

    John Henry Donovan

    12339 posts

    Thanks Ryan. Feel free as always to start a new thread if you have any more questions.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases