Skip to content

Add id to index form - #2123

Merged
Flo0807 merged 1 commit into
developfrom
feature/index-form-id
Jul 20, 2026
Merged

Add id to index form#2123
Flo0807 merged 1 commit into
developfrom
feature/index-form-id

Conversation

@Flo0807

@Flo0807 Flo0807 commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Index forms rendered by the built-in fields carry phx-change but no id. Without an id LiveView cannot perform form recovery after a crash or disconnect, and Phoenix.LiveViewTest reports a missing_form_id warning for every render.

This follows #2122 (per-page select form) and #2089 (filter form), which fixed the same class of warning elsewhere.

Changes

Adds an id to the index form in the nine fields that render one: belongs_to, boolean, date, date_time, email, number, select, text, time.

The id reuses the expression already used for the index form input directly below it:

id={"index-form-#{@name}-#{LiveResource.primary_value(@item, @live_resource)}"}

That keeps it unique per field and per item, and correct for resources with a custom or composite primary key.

Also adds an id to the <.form> in the edit_card/1 doc example, so the documented pattern doesn't demonstrate the thing that triggers the warning.

Verification

  • mix lint — compile with --warning-as-errors, format, and credo all clean
  • MIX_ENV=test mix test — 100 doctests, 174 tests, 0 failures

Without an id, LiveView cannot perform form recovery after a crash or
disconnect, which Phoenix.LiveViewTest reports as a warning.

The id mirrors the one already used for the index form input, so it is
unique per field and item.
@Flo0807 Flo0807 added the bug Something isn't working label Jul 20, 2026
@Flo0807 Flo0807 self-assigned this Jul 20, 2026
@Flo0807
Flo0807 enabled auto-merge July 20, 2026 08:02
@Flo0807
Flo0807 added this pull request to the merge queue Jul 20, 2026
Merged via the queue into develop with commit de32559 Jul 20, 2026
8 checks passed
@Flo0807
Flo0807 deleted the feature/index-form-id branch July 20, 2026 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant