Formit - Behaving Badly

MODX 2.7.3
Bootstrap 4.5.0
Formit 4.2.5

Simple contact form using FormIt example with few mods:
Here’s my call:

 [[!FormIt?
        &submitVar=`contactform`
        &hooks=`spam,email,redirect`
        &emailTpl=`contactTpl`
        &emailTo=`me@myemail.com`
        &redirectTo=`35`
        &validate=`name:required,email:email:required,subject:required,text:required:stripTags`]]
        <div>[[!+fi.validation_error_message:notempty=`<p>[[!+fi.validation_error_message]]</p>`]]</div>
        <form class="form" action="[[~[[*id]]]]" id="contactform" method="post">
          <input name="contactform" type="hidden" value="1" />
          <div class="form-group">
            <label for="name"> Name:(required)<span class="error text-danger">[[!+fi.error.name]]</span></label> 
            <input id="name" class="form-control" name="name" type="text" value="[[!+fi.name]]" />
            </div>
          <div class="form-group">
            <label for="email"> Email:(required)<span class="error text-danger">[[!+fi.error.email]]</span></label>
            <input id="email" class="form-control" name="email" type="text" value="[[!+fi.email]]" />
            </div>
          <div class="form-group">
            <label for="subject"> Subject:(required)<span class="error text-danger">[[!+fi.error.subject]]</span></label>
            <input id="subject" class="form-control" name="subject" type="text" value="[[!+fi.subject]]" />
            </div>
          <div class="form-group">
            <label for="text"> Message:(required) <span class="error text-danger">[[!+fi.error.text]]</span></label>
            <textarea id="text" class="form-control" name="text" rows="5">[[!+fi.text]]</textarea>
            </div>
                <button class="btn btn-primary" type="submit">Submit</button>
        </form>

Here’s what’s happening:

The initial FormIt that I wrote - similar to this, a bit different validation, works. But if I change anything such as adding CC or BCC or changing validation it fails and renders a blank page. This behavior happens as long as I put the FormIt call and form directly in the content area.

If I use a chunk for all of the FormIt content the page renders with the form on top followed by a correct rendering of the page. And the form works fine - the page is totally broken.

I’m sure I’m using the submitVar wrong, but this form didn’t work initially and submitVar has since been removed. Suggestion on using that correctly would be very kind.

I’ve done a lot of troubleshooting based on what is on the forum as well as thoroughly scrubbing the template markup and code. Every other page on the site works fine. I’m ready for some help.

Thanks,

Not sure if I get your entire problem correctly but in regards to the &submitVar, you want to place that value in your input type="submit" tag as a name attribute like the docs mention. That applies only if you use multiple forms on one resource though, so if you have just one form you can simply leave it out:

If you have multiple forms on a page, set the &submitVar property on your Snippet call to a name of a form element within the form (ie, &submitVar=form1-submit`` ). This tells FormIt to only process form requests with that POST variable. Multiple forms should be used with INPUT type=“submit” name=“form1-submit”, button elements have been reported not working.

Also note that apparently button elements have been reported not working.

A few other thinks, which might help solve your issue:

  • you’re missing your two closing brackets -> ]] (in case that was not just left when copying to this thread)
  • check if your general email setup works fine with QuickEmail
  • check the mail system settings, especially regarding your SFTP credentials. I had it happen in the past, that emails won’t send anymore because the provider restricted all non-encrypted emails

Hope that helps!

Further to @vibedesign’s comment, if this is the only form on a page, there’s no need for a submitVar at all. It’s only used to target the submit input/button if there are multiple forms in a view.

Thank you for your reply vibedesign - I verified that the brackets were there - they just didn’t copy over for some reason… email works fine. I’m doing some more testing, but will post further if I’m still stuck with this problem.

Thank you smashingred - submitVar has been removed - still having the problem. Will further post after some more testing.