0

I have an event template that pulls in a Freeform Pro field, via the Freeform Pro fieldtype, which relates a form to an entry. I'm having problems with a reoccurring error that says "Invalid form id(s)":

{exp:ce_cache:it id="events-{segment_2}-mobile_{gv_device_is_mobile}" tags="event"}

    {exp:stash:set_list
        name="event-{segment_2}"
        parse_tags="yes"
        parse_depth="3"
        parse_conditionals="yes"
        save="yes"
        refresh="60"
        scope="site"
        replace="yes"
    }
        {exp:channel:entries
            channel="event"
            cache="yes"
            refresh="60"
            disable="member_data|pagination|trackbacks"
            show_expired="no"
            status="open"
            require_entry="yes"
        }

            {stash:event_title}{title}{/stash:event_title}
            {stash:event_id}{entry_id}{/stash:event_id}

            {!-- This is my Freeform Pro Fieldtype https://www.solspace.com/docs/freeform/channel_entry_fieldtype/ --}
            {stash:event_form}{event_form}{/stash:event_form}

        {/exp:channel:entries}
    {/exp:stash:set_list}

    {exp:stash:set name="content"}
        {exp:stash:get_list
            name="event-{segment_2}"
        }
            <h1>{event_title}</h1>

            {exp:ce_cache:escape}
                {if event_form}
                <div class="wb bt">
                    <div class="inner">
                        {event_form}
                    </div>
                </div>
                {/if}
            {/exp:ce_cache:escape}

        {/exp:stash:get_list}
    {/exp:stash:set}

{/exp:ce_cache:it}

As you can see, I'm using Stash to set all of the data related to the entry and {stash:event_form} captures the Freeform Pro fieldtype. I'm also using CE Cache on the page, but i'm using CE Cache Escape tags {exp:ce_cache:escape} around the actual form.

I was wondering if someone can tell me if I need to be doing anything else to prevent this error? I can fix it temporarily by deleting the page from CE Cache, but eventually it reoccurs - presumably after someone completes a form on another entry.

  • 1
    Don't cache the form. You're already caching the output of channel:entries so there's no much to gain by further caching the page. These caching guidelines are for Stash, but apply to ce_cache too: github.com/croxton/Stash/wiki/Caching – Mark Croxton May 12 '15 at 16:43
  • Thanks Mark. Should I just remove the exp:ce_cache:it tags? – doubleplusgood May 12 '15 at 18:26
  • Or add the stash:nocache tag around event_form in exp:channel:entries? – doubleplusgood May 12 '15 at 18:33
  • 1
    I'd remove the cache:it tags. – Mark Croxton May 14 '15 at 12:48
1

We never recommend caching a form because it has a unique identifier from ExpressionEngine for CSRF protection that's generated per page as well as a unique identifier from Freeform used to prevent spamming, malicious form manipulation, and to assist in multipage forms.

You are getting the invalid form ID error because the cached form isn't able to regenerate the params ID Freeform needs to function properly.

| improve this answer | |
  • Thank you. I guess I thought that using the escape tags would prevent this. Should I just remove the exp:ce_cache:it tags or take the event_form out of the stash set_list? – doubleplusgood May 12 '15 at 18:28
  • Since we're not familiar with Stash + CE Cached used together, we can't really say what is best practice here (lots of parse order and cache bending going on). Whatever you end up doing, the form's hidden csrf_token field value must not be cached for the form to work. Perhaps taking Stash out of the equation would work here though (i.e. just deal with cache and cache busting to the form part). – Solspace May 14 '15 at 13:00

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.