1

I'm trying to pass an entry field type "Formfield" into a template. I have it working without passing any custom values through but when I do it outside of the render tag, No matter what I do I am getting an error saying null variable cannot render. Thoughts?

ie: (Below works)

{{ entry.contactFormHandle.render() }}

But: (Does Not) in many variables and difference does not...

{{ craft.freeform.form("{entry.contactFormHandle}", {
                        labelClass: "my-label-class",
                        inputClass: "my-input-class",
                        submitClass: "my-button-class",
                        instructionsBelowField: true,
                        overrideValues: {}
                    }).render() }}         
  

I'm sure it's something stupid. Any help would be appreciated!

2 Answers 2

1

Welcome to Stack Exchange! Yes, your syntax is wrong - you need to remove the curly brackets around entry.contactForm.handle, and the quotations, and actually get the handle.

{{ craft.freeform.form( entry.contactForm.handle,
    {
        instructionsBelowField: true
    }
).render() }}

Source: Freeform docs

2
  • I tried this, but it actually returns the same error where it's trying to render a null variable. "Impossible to invoke a method ("render") on a null variable."
    – Ben
    Commented Apr 20, 2021 at 15:01
  • I've updated my answer; and you'll also want to wrap it in a conditional to make sure the form exists before you try to get it's handle. Commented Apr 21, 2021 at 10:35
0

I think you'll need entry.contactFormHandle.handle. Freeform's form select field doesn't select the form handle, it selects the form, so you need to get more specific in drilling down to the handle.

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.