Shopify / Shopify/liquid

Form tag doesn't include the form.id

Open
#1,650 5 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
11.9k
Forks
1.5k
Avg merge
17h 55m
Merged PRs (30d)
3

Description

Issue

When creating a form such as

{% form 'customer', id: 'ContactFooter' %}
  <span>{{ form.id }}</span>
  [...rest of content...]
{% endform %}

the form.id is nil

Expected

The form object id should be the id of the submitted form and be available within the form. This is especially useful when you might have multiple forms on the page and you want to use form.errors or form.posted_successfully?. Currently, you cannot identify which form actually has the errors. If you try to use those properties, both forms display errors. It would be awesome, if you could do something like:


{% form 'customer', id: 'SomeOtherForm' %}
  {% if form.errors and form.id == 'SomeOtherForm' %}
  [...errors for SomeOtherForm...]
  {% endif %}
{% endform %}


[...more content on the same page...]

{% form 'customer', id: 'ContactFooter' %}
  {% if form.errors and form.id == 'ContactFooter' %}
  [...errors for ContactFooter...]
  {% endif %}
{% endform %}

Discussion

Is having form.id always equal to nil expected behaviour?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the form tag and the form object behavior shown in the issue, tracing how the supplied id is handled inside the form block. Add coverage for multiple forms and verify that form.id reflects each tag's id and allows errors or success state to be distinguished.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.