amforms icon indicating copy to clipboard operation
amforms copied to clipboard

File attachment causes form submission to fail

Open CreateSean opened this issue 8 years ago • 5 comments

I read this closed issue and have ensured that I have this added to my form tag enctype="multipart/form-data"

However the form still fails. Without attaching a file the form submits correctly but when adding an attachment it fails. The form submits but does not go to the redirect page and no data is saved.

My simplified form is here:

<form method="post" accept-charset="UTF-8" class="form-horizontal contact-form" enctype="multipart/form-data">
{# This should always be here! #}
<input type="hidden" name="action" value="amForms/submissions/saveSubmission">

{# Insert your forms handle. #}
<input type="hidden" name="handle" value="requestQuote">

{# Optional: Redirect URL. Will redirect to current page by default. #}
<input type="hidden" name="redirect" value="contact/thankyou">

{# Optional: Anti-spam protection. #}
  {{ craft.amForms.displayAntispam() }}

  {# Optional: Google reCAPTCHA protection. #}
  {{ craft.amForms.displayRecaptcha() }}

  <fieldset class="row">

    <div class="col-sm-6">
        <label class="sr-only control-label" for="textinput">Name</label>
        <input id="name" name="fields[fullName]" type="text" placeholder="Name" class="form-control input-md" required>

    </div>

    <div class="col-sm-6">
        <label class="sr-only control-label" for="Email">Email</label>
        <input id="email" name="fields[emailAddress]" type="email" placeholder="Email" class="form-control input-md" required>

    </div>
    
      {{ form.displayField('attachment') }}
    
    <!-- Button -->
    <div class="col-sm-12">
      <button id="singlebutton" type="submit" name="singlebutton" class="btn btn-primary">Submit</button>
    </div>

  </fieldset>


</form>

Craft 2.6.2967 A&M Forms 1.6.1

Please advise.

CreateSean avatar Mar 29 '17 15:03 CreateSean

When you output the source, what is the name of your attachment field? I'm thinking that the namespace is in place.

hubertprein avatar Mar 30 '17 12:03 hubertprein

Hubert,

This is what I see in the source:

In the A&M settings the field handle is "attachment" and set to a limit of 3. If I edit a successful form submission I can add a file. Just can't do it from the front end of the site.

CreateSean avatar Mar 30 '17 13:03 CreateSean

I can't see the source I'm afraid.

hubertprein avatar Mar 30 '17 14:03 hubertprein

sorry, this time with code tags

<input type="file" id="fields-attachment" name="fields[attachment][]" multiple="">

CreateSean avatar Mar 30 '17 14:03 CreateSean

Late reply.. But I do think that what you have there should be correct.

If you place the form in Twig with {{ craft.amForms.displayForm('yourHandleHere') }} and run it then, does that work well?

hubertprein avatar Jun 12 '17 11:06 hubertprein