0

I'm trying to create a form with Freeform Pro containing a File Upload field that is required. So the form should only submit when the user actually uploads a file.

Setting the field to required in template parameter seems to have no effect.

Bug or missing feature? Any workarounds?

{exp:freeform:form form_name="feedback" secure_action="yes" secure_return="yes" required="some_picture|email" form:id="some_form" admin_notification_template="feedback_notify" admin_notify="foobar@example.com" prevent_duplicate_on="email" inline_error_return="group/template" inline_errors="yes" return="group/feedback_thanx"}

<label for="fmail">
<span class="frage"{if freeform:error:email} style="color:red;"{/if}> E-MAIL </span>
{freeform:field:email id="fmail"}
</label>

<label for="some_picture">
<span class="frage" {if freeform:error:some_picture}style="color:red;"{/if}>Please upload! </span><br><br>
{freeform:field:some_picture id="some_picture"}
</label>

<input type="submit" name="submit" value="Absenden" />
{/exp:freeform:form} 
4
  • Is this using Composer (i.e. {exp:freeform:composer}) or regular Freeform template code (i.e. {exp:freeform:form})? Can you show us your code? Also, what version of Freeform are you using?
    – Solspace
    May 30 '14 at 21:01
  • Using regular Freeform template code. Code added above. Version 4.1.8.
    – user1013
    Jun 9 '14 at 0:03
  • 1
    Is some_picture a field created in Freeform's module in the CP? Is it spelled correctly? Is the field assigned to your feedback form? Have you tried the above code COMPLETELY alone on a blank template? Please try that in case other tags are affecting your form. Tested with a required file upload field and it worked.
    – Solspace
    Dec 2 '15 at 2:29
  • 1
    Also, unrelated but it should be attr:id="some_picture", not id="some_picture".
    – Solspace
    Dec 2 '15 at 2:30
1

You can make it required by adding an hidden input with the same name as your file input:

{exp:freeform:form required="file_upload"}

  {freeform:field:file_upload show="1"}
  <input type="hidden" name="file_upload">

  <button type="submit">Send</button>

{/exp:freeform:form}

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.