<p>It's giving you errors because you put the variable in quotes. Ditch the quotes and try it like this...</p>

<pre><code>{% set form = craft.formBuilder2.getFormByHandle(entry.formName) %}
</code></pre>

CC BY-SA 3.0
2018-01-31T04:32:13.960Z
When I do that I get Internal Server Error "Trying to get property of non-object"
kingkelly
CC BY-SA 3.0
2018-01-31T04:32:59.363Z
What is `block`? I assumed that was a matrix block (or similar).
Lindsey D
CC BY-SA 3.0
2018-01-31T04:37:58.163Z
sorry, its just a good ole Plain Text field
kingkelly
CC BY-SA 3.0
2018-01-31T04:39:45.417Z
Updated my example. Assuming you're on a normal entry page, change `block` to `entry`.
Lindsey D
CC BY-SA 3.0
2018-01-31T04:29:31.090Z
2018-01-31T04:38:36.643Z
2018-01-31T04:38:36.643Z
Lindsey D
<p>My template has this line that I want to update from a field in craft: </p>

<pre><code>{% set form = craft.formBuilder2.getFormByHandle('schoolTrip') %}
</code></pre>

<p>I want 'schoolTrip' to be replaceable by a plain text field in craft. My plain text field is named 'formName'.</p>

<pre><code>{% set form = craft.formBuilder2.getFormByHandle('block.formName') %}
</code></pre>

<p>just gives me errors.</p>

<templating><form><plugin-formbuilder2>
Pass variable in Twig tag
# Pass variable in Twig tag

(Asked by: username_0 on 2018-01-31)

My template has this line that I want to update from a field in craft: 
{% set form = craft.formBuilder2.getFormByHandle('schoolTrip') %}

I want 'schoolTrip' to be replaceable by a plain text field in craft. My plain text field is named 'formName'.
{% set form = craft.formBuilder2.getFormByHandle('block.formName') %}

just gives me errors.

**Tags:** templating, form, plugin-formbuilder2


---

## 1 answers

### Answer by username_1 on 2018-01-31. Score: 2 | Accepted answer

It's giving you errors because you put the variable in quotes. Ditch the quotes and try it like this...
{% set form = craft.formBuilder2.getFormByHandle(entry.formName) %}

> **Comments:**
> **username_0**: When I do that I get Internal Server Error "Trying to get property of non-object"  
> **username_1**: What is `block`? I assumed that was a matrix block (or similar).  
> **username_0**: sorry, its just a good ole Plain Text field  
> **username_1**: Updated my example. Assuming you're on a normal entry page, change `block` to `entry`.  

---

