I’m working on a development store and whenever I try to access the form.id inside of a form tag, it’s alway blank. Is there a way to get an id for the form?
{% form 'contact', id: "contact-form" %} {{ form.id }} {% endform %}
I’m working on a development store and whenever I try to access the form.id inside of a form tag, it’s alway blank. Is there a way to get an id for the form?
{% form 'contact', id: "contact-form" %} {{ form.id }} {% endform %}
Yes, it is possible to get an id for a form in Shopify using the id parameter in the form tag. This will allow you to access the id of the form using the form.id variable in your liquid code.
Here is an example of how you can use the id parameter to get an id for a form in Shopify:
{% form ‘contact’, id: “contact-form” %}
{{ form.id }}
{% endform %}
In this example, the id parameter is used to set the id of the form to “contact-form”. This id can then be accessed using the form.id variable within the form tag.
When I try using that exact example you provided, the {{ form.id }} tag doesn’t output anything. Is there something I’m missing? ie. does it only output the id if the form is submitted, does the form need to be in a specific template?
The {{ form.id }} tag will output the id of the form as long as the id attribute of the form tag is set. It does not matter whether the form has been submitted or not.
This does not work.