Roots Discourse

Sage HTML Forms by Log1x - Email body blank

First of all, I really appreciate all the packages Brandon has created. I really own him a beer. This is the first time I’ve attempted to use his Sage HTML Forms package and I’m having some issues with it. Hope someone has some more experience with it than I do and can help out.

Ok, so I’ve created a contact form:

<x-html-forms
    :form="$form"
    id="contact"
    class="flex flex-wrap w-full space-y-8"
>
    <div class="space-y-8 lg:space-y-0 lg:flex lg:space-x-8 w-full">
        <div class="w-full lg:w-1/2">
            <input
                name="name"
                type="text"
                class="w-full border border-pantone-285c-30 px-4 py-2 placeholder-gray-500"
                placeholder="Name..."
                required
            >
        </div>
        <div class="w-full lg:w-1/2">
            <input
                name="email"
                type="email"
                class="w-full border border-pantone-285c-30 px-4 py-2 placeholder-gray-500"
                placeholder="Email Address..."
                required
            >
        </div>
    </div>
    <div class="flex space-x-8 w-full">
        <div class="w-full">
            <textarea
                name="message"
                class="w-full border border-pantone-285c-30 px-4 py-2 placeholder-gray-500"
                placeholder="Please tell us how we can help you..."
                rows="6"
                required
            ></textarea>
        </div>
    </div>
    <div class="flex w-full justify-end">
        <input
        type="submit"
        value="Submit"
        class="btn-md bg-white hover:bg-opacity-80 cursor-pointer border border-pantone-285c-30 "
      />
    </div>
</x-html-forms>

This automatically produces this in the HTML Forms plugin:

When submitting a form with the following settings, the form processes and saves the form submission in the submissions tab as it should with all the field data. However, the form is not hidden and the inputs still container the data.


If instead I redirect to a /thank-you page, the form is cleared after submitting, the thank you message appears and then it successfully redirects me to my thank you page.

The major problem here is with the emails. They’re being sent with empty bodies.

This is how I’ve setup my action to send an email:

According the the brief documentation on this package, Brandon mentions:

When HTML Forms processes "Form Actions" – it simply fetches each input name to create the usable variables.

That being said, the default view would provide  `[NAME]`  and  `[EMAILADDRESS]` .

So it appears I’ve done everything correctly. Does anyone have any idea whats up? Kindly-

I’ve just confirmed that if I use HTML Forms as it is intended, then the body is sent out with the email. So I guess eliminates the plugin itself and I am either doing something wrong with Sage HTML Forms or there is a bug.

how are you using the form in a template? are you using the @htmlform directive? I should probably extend the docs but the form its self needs to be called using hf_get_form().

Hi yes, I was using @htmlform
I had originally set up a few forms weeks ago with Sage HTML Forms and have been struggling to get them to send emails.

I created a new form this morning and the new form works but the previous ones do not. They were all setup the same way so I don’t know why the first couple of forms do not work. I have to create new forms with different slugs for them to work. I struggle with blade cache issues on this machine so it could have been part of that.

The only thing left not working with this setup is hiding the form after a successful completion.

Thanks for chiming in Brandon.

HTML Forms plugin suggests using wpbruiser for anti-spam. I’ve set this up but receive the following message attempting to submit any forms:

“Your submission seems to be a spam!”

wpbruiser does work and will not deliver the message if you use HTML Forms alone without Sage HTML Forms.

Has anyone had any luck with this?
I’ll likely just setup recaptcha but it would be super cool to be able to use wpbruiser instead.

Hey!

I’ve been wrestling with HTML Forms for a couple of hours now myself. Like the issue @joshb initially had, the emails are not populated with any actual data :thinking:


Looking over at the issues for HTML Forms, it seems like this is to be expected though:

Which makes it all the more curious that it works for you now @joshb

I add my forms via the Gutenberg block provided by HTML Forms. Is that expected to work @Log1x? I’m on HTML Forms 1.3.22 for clarity.

Awesome package none the less, thanks so much!

Not 100% sure if the Gutenberg block will work as I haven’t personally tested it.

I instead add it using the built in @htmlform Blade directive into a template.

I’m using this in 3-4 production sites and haven’t had any noticeable issues – but it’s possible HTML Forms did an update that broke something.

I can’t recall exactly how I was able to get my email body data working. I think I had to remove all the variables, save the HTML Form, add them back again and save.

@Log1x - Brandon, can I ask what you use for spam on your forms? HTML Forms suggests using WPBruiser but that doesn’t appear to be compatible with Sage HTML Forms.

I need to figure out a solution still tbh. :frowning:

Right on. Do you know if you get a lot of spam on your forms?
Previously I was using Ninja Forms with recaptcha and would get hundreds of Canadian Pill entries.

Spam to buy links mostly, but with the email address going through Google it stays relatively clean with a few filters.

I definitely want to figure out a Captcha solution with HTML Forms, I was briefly messing with it but think I lost what I had.

1 Like

Do you mean clearing out “Message” in the the email submissions setup and then adding back the variables again? Do you have anything in “Form code” under Fields or is that blank?

@Log1x Tried using the directive, but same result unfortunately.

What versions are you on that works for you?

Yes, my form code is empty. IIRC, I removed all the variables and the form code, then saved changes and added the variables back based on what I used to build the form within Sage HTML Forms.

Seems like the issue was that I was setting name="email" on the input and then setting [EMAIL] in the message. Switched to name="EMAIL" and now it works.

1 Like