1

I'm getting the following error:

An exception has been thrown during the rendering of a template ("Craft\SproutForms_EntryModel and its behaviors do not have a method or closure named "CONTACTFULLNAME".") in "CONTACT FORM ENQUIRY FROM: {{object.CONTACTFULLNAME|raw}}

The form has the following fields:

contactFullName email message

The email notification fields for the first email Contact Form - Thank You message contain:

Subject: Contact Form - Thank You ​{contactFullName}

Message: Thank you for contacting us, {contactFullName}. We will be in touch soon.

And for the other email:

Subject: Contact form enquiry from: {contactFullName}

Message: You have received an enquiry Enquiry from {contactFullName} - {email} “{message}”

Can anyone shed any light onto why this capitalised reference to the CONTACTFULLNAME missing method or closure (by this I presume field) appears in the logs? The form is getting saved, but no email sent due to this message.

  • Running Craft CMS 2.6.2780, Sprout Email 2.2.3, Forms 2.2.5 – Adam Menczykowski Apr 28 '16 at 14:37
  • Have you tried using {entry.contactFullName}? Picked this up from the docs here: sprout.barrelstrengthdesign.com/craft-plugins/email/docs/… – Luke Pearce Apr 28 '16 at 15:21
  • Hi Luke thanks I have just tried swapping out the references to that field with {object.contactFullName}, however that just throws a different error: An exception has been thrown during the rendering of a template ("Craft\SproutForms_EntryModel and its behaviors do not have a method or closure named "entry".") in "Contact form enquiry from: {{object.entry.contactFullName|raw}}" at line 1. – Adam Menczykowski Apr 28 '16 at 15:30
2

Variables in Craft are case sensitive. You'll run into the same error if you try to output the Craft {{ siteName }} global as {{ SITENAME }}.

Updating the casing to {contactFullName} or {{ object.contactFullName }} should get things working for you.


An extra note regarding the comments above. Luke is onto the right answer in the comments, however, one more distinction needs to be made. There are multiple variables available to your Sprout Email templates. To quote the docs linked in Luke's comment:

In your notification templates you can use any Twig code that you would use elsewhere in your templates. Additionally, Sprout Email Notifications give you access to the Notification Email Object (entry) and any Dynamic Object provided by the event (object)

Your variable contactFullName is not a field on your Notification Email Entry, it's a field on your Sprout Forms Submission Entry. It's correct that you would get an error trying to refer to it as {entry.contactFullName} because 1) the Notification Email doesn't have that field and, 2) the shorthand syntax is going to add the object variable behind the scenes, so the variable would be seen as {{ object.entry.contactFullName }}.

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.