I am trying to use a variable, based on an entry field, to load a form with a Twig include. The code is pretty straightforward:

{% set theForm = entry.formSelect %}
{% include theForm %}

Doing this throws this error:

Undefined property: Craft\SingleOptionFieldData::$cacheKey

If I print the variable, it looks exactly as you would expect, e.g. forms/_basic

Any suggestions would be appreciated!

  • maybe try entry.formSelect.value? Commented Mar 12, 2015 at 19:21

1 Answer 1


You need to let Twig interpret the variable as a string. This works for me:

{% set theForm = entry.formSelect %}
{% include ''~theForm~'' %}

Hope this helps!


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.