1

I'm working on a site that was partially built by another dev and am having some trouble with Sprout Forms.

It's partially working but when I add a new field (sailSeries) to the template (it exists in the sprout forms control panel) I get this error:

Craft\SproutForms_EntryModel and its behaviors do not have a method or closure named "sailSeries".

Expanding on what the original dev has I added the sails series inside this for loop at the bottom.

{% for tab in form.getFieldLayout().getTabs() %}
    {% set fields = tab.getFields() %}

    {% for field in fields %}

      {% set required = field.required %}
      {% set tabId = field.tabId %}

      {% set field = field.getField() %}

      {% if field.handle == 'contactType' %}
       {% set dropdownField = field %}
      {% endif %}

      various more fields


      {% if field.handle == 'sailSeries' %}
        {% set  sailSeries = field %}
      {% endif %}

    {% endfor %}
{% endfor %}

The the code later in the template to have the field display:

<div class="frm-row">
<div class="section colm colm6">

    {% set submittedDropdownValue = attribute(submittedEntry, sailSeries.handle) %}

    <label class="field select">
      {{ sailSeries.name }}
        <select id="sailSeries" name="sailSeries">
        {% for option in sailSeries.settings.options %}
            {% set defaultValue = option.default ? option.value : null %}
            {% set selectedDropdownValue = submittedDropdownValue != '' ? submittedDropdownValue : defaultValue %}

            <option value="{{ option.value }}" {% if selectedDropdownValue == option.value %}selected="selected"{% endif %}>{{ option.label }}</option>
        {% endfor %}
        </select>
        <i class="arrow"></i>                    
    </label>  
</div><!-- end section --> 
</div><!-- /.frm-row -->

As soon as I add this in I get errors. Not sure why or how to troubleshoot. Please advise.

Revised code and now I'm getting this error:

Variable "sailSeries" does not exist.

no clue why this is happening.

5
  • Probably obvious, but is the field listed in the form in the control panel? Commented Jul 12, 2017 at 14:58
  • @erwinheiser yes it is.
    – CreateSean
    Commented Jul 13, 2017 at 13:43
  • @CreateSean Are you getting the error when you load the form page the first time or after you submit the form? The second block of code appears to be displaying information after the form is submitted in which case you may have to check if the sailSeries variable is defined on the initial page load before form submission. Commented Jul 14, 2017 at 11:15
  • @BenParizek This error is on page load. The form is in an include - should these variables be defined on the page where the include is called?
    – CreateSean
    Commented Jul 14, 2017 at 12:59
  • @CreateSean I'd have to see the full template code, but the Submitted Entry SproutForms_EntryModel is going to be null until after you submit a form. Once a form is submitted, a Form Entry is created and the form values are returned to the page as a SproutForms_EntryModel. On the first page load (before a form is submitted), you'll need to check and confirm that the SproutForms_EntryModel exists before you try to access any attributes that it contains. Commented Jul 14, 2017 at 13:20

1 Answer 1

1

Make sure those "missing" fields aren't used in the title format (under the advanced tab) or in your notifications - both in the control panel. Ran into something similar just now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.