Related select field not updating after phx-change

With a setting like below, and a put_change for program_id based on a custom validation rule for name, in the phx-change handle event, nothing happens for the select field

the program_id put _change is well reflected in the @changeset, but the select field does not move to the right value. If I put a text input field instead of the select, the put_change value is well reflected in the text input field.

the value in the put_change does exist in the select @options

<.form let={f} for={@changeset} id: “form” phx-target={@myself}, phx-change= “validate”, phx-submit= “save” >

    <%= text_input f, :email %>                                         
                                                                        
<%= inputs_for f, :manyrel, fn v -> %>                             
    <%= text_input v, :name %>                                 
    <%= select v, :program_id , @options%>      

<% end %>
</.form>

the correct value can be accessed with

Changeset.get_fied(v.source, :program_id) and so manually forced with

<%= select v, :program_id , @options%, value: Changeset.get_field(v.source, :program_id) %>

but how come it auto updates for a text field and not for a select field ?

I am having this same issue. Did you figure out a workaround?

No but the last line was the workaround

I’ve discovered a similar issue. For me it seems, that the “selected” attribute of an select option is not updated correctly like discribed in this issue: Unexpected DOM behavior on selecting an option within a select tag · Issue #1883 · phoenixframework/phoenix_live_view · GitHub.
When using an older version (0.15.4) of Phoenix Liveview everything worked as expected but with the upgrade to the newest version there seems to be a change of this behavior. I’m not sure if this is intended or not. Do you have any new insights on this problem?

3 Likes