Sprout Forms Confirmation Page Field Not Defined I'm trying to create a confirmation page for a Sprout form, where I want to check if a certain field is present, and if so, check for a value, so I can return a message based on that value.

I'm using lastEntry, and am able to pull the valid fields in without a problem, but it's having issues checking whether the field is defined. I'm currently using the following code:

{% set lastEntry = craft.sproutForms.lastEntry() %}
{% set qualified = true %}
{% if lastEntry.fieldName is defined and lastEntry.fieldName == 'no' %}
    {% set qualified = false %}
{% endif %}


When I use the code above, and the field has not been used in the particular form, I see:
Craft\SproutForms_EntryModel and its behaviors do not have a method or closure named "fieldName".

It appears Craft is seeing the field as defined, but not. Anyone have any ideas on what I could do to figure this out?

Thanks!
When you set the lastEntry variable on your page. You are either setting lastEntry to be the SproutForms_FormEntryModel or null. In both cases you are defining the variable.

{# Sets lastEntry to SproutForms_FormEntryModel or null #}
{% set lastEntry = craft.sproutForms.lastEntry() %}


If you then want to test the lastEntry variable, you'll need to use something different that is defined.

I believe the following will work:

{% set lastEntry = craft.sproutForms.lastEntry() %}
{% set qualified = true %}
{% if lastEntry and lastEntry.fieldName == 'no' %}
    {% set qualified = false %}
{% endif %}


Testing for if lastEntry will work just like using if lastEntry is not null. The secondary part of your conditional should only be evaluated if if lastEntry returns true, in which case your SproutForms_FormEntryModel would exist and the fieldName field would be defined, with or without a value.