2

I'm getting an error on my options template when I run the report, the sprout from can't find the form fields template and I get this error

Unable to find the template “_includes/forms” in "__string_template__1e75d07f7afb92cfc030941cdd0c214a5067c25743f143e36dcfc3dd77a06f62" at line 1.

When I remove the import I get this error

Variable "forms" does not exist in "__string_template__68fd366166a1d3cc8e58752e3634a261ca9faaa526e284d487e82cc2434316c9" at line 2.

Here is my options.twig

{% import '_includes/forms' as forms %}

{% set limitByDateRange = settings.limitByDateRange ?? false %}

{{ forms.lightswitchField({
    label: 'Filter By Date Range'|t,
    name: 'limitByDateRange',
    on: limitByDateRange,
    value: 1,
    toggle: 'toggle-dateRangeFields',
    first: true
}) }}

<div id="toggle-dateRangeFields" class="{% if not limitByDateRange %}hidden{% endif %}">
    {{ forms.date({
        label: 'Start Date'|t,
        id: 'datetimeStartDate',
        name: 'datetimeStartDate',
        value: settings.datetimeStartDate is defined ? settings.datetimeStartDate : now|date_modify('-1 month')
    }) }}

    <p style="display: inline-block;margin: 0 5px;">to</p>

    {{ forms.date({
        label: 'End Date'|t,
        id: 'datetimeEndDate',
        name: 'datetimeEndDate',
        value: settings.datetimeEndDate is defined ? settings.datetimeEndDate : now
    }) }}
</div>

{%- js %}
    $('#options-datetimeStartDate-date').datepicker($.extend({
        defaultDate: new Date({{ now.year }}, {{ now.month-1 }}, {{ now.day }})
    }, Craft.datepickerOptions));

    $('#options-datetimeEndDate-date').datepicker($.extend({
        defaultDate: new Date({{ now.year }}, {{ now.month }}, {{ now.day }})
    }, Craft.datepickerOptions));

    $('#modify-options-panel').attr('style', null);
{%- endjs %}

I also already tried to copy the examples templates from the plugin folder and I get the same error. Does anyone have an idea what could be wrong? I appreciate any help, thanks.

  • Can you confirm what version of Craft and Sprout Reports you are using? I believe this issue was introduced in Craft CMS v3.3.7 and solved updating to Sprout Reports v1.2.8. – Ben Parizek Oct 23 '19 at 23:04
  • Hi Ben thanks for your reply, I'm using Craft CMS 3.3.1.2 and Sprout Reports 1.2.7 – Luiz Machado Oct 23 '19 at 23:10
2

As Ben Parizek pointed out in the comments this was a bug that was fixed on Sprout Reports 1.2.8.

I couldn't see Sprout Reports update because my Craft CMS installation was below v3.3.7, I updated Craft CMS and then updated Sprout Forms to v1.2.8 which fixed the bug.

| improve this answer | |

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.