EEx template generating different IDs for several form inputs in dev and prod/staging

I stumbled upon a form that is similar to the following (changed some names):

<%= form_for @changeset, @action, [id: "product_form"], fn f -> %>
   ...
   <%= select(f, :material_id, @materials, prompt: "Pick material") %>
   ...
   <%= select f, :order_id, @orders, class: "add-bottom-margin", prompt: "Pick order" %>
  ...
<% end %>

I noticed that in development the two selects have ids respectively "product_material_id" and "product_order_id". In staging however (and production, they use the same config but have different environment variables), they have ids "product_form_material_id" and "product_form_order_id".

The same EEx template is used in both cases and there are no conditions in it that have branching logic depending on the environment.

Why would different IDs be generated in this case? In development I have phoenix_html version 2.14.2 and in staging it is 2.14.3 but as far as I can see from the changelog between the two there are no big changes.

It seems like I might be missing something fundamental and this is a relatively new code base to me, but this problem has been baffling me all day and I have not been able to find what it could be related to. I manually defined the IDs in the form in the end, but I am curious as to why this difference occurred in the first place.

1 Like

Check the version of phoenix_ecto in each - a change with exactly the behavior you’re seeing shipped in 4.2.1 Multiple forms rendering dynamically in the same page · Issue #1014 · phoenixframework/phoenix_live_view · GitHub

2 Likes

This seems to be it. In development I have 4.1.0 while in staging it is 4.3.0. Thank you very much!