blset

blset

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 ?

Most Liked

alexbaetz

alexbaetz

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?

Where Next?

Popular in Questions Top

lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
Werner
Hi, I’m using Ubuntu 18.04 and after updating to OTP-24.0 yesterday i have this warning when I run “mix local.hex”: 14:57:30.512 [warn] ...
New
Phillipp
Hey, I have a NanoPi-M3 and try to install Elixir on their Ubuntu image. I followed the Raspberry Pi installation instructions from the ...
New
mathew4509
I have a list say x = ["23gh", "56kh", "97mh"] I would like to pass each element to Val in each iteration. Say, in iteration 1 -------...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
Codball
Mix format works fine if run from the cmd. I’ve followed this to facilitate the implementation into VSC which involves downloading an ext...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
jc00ke
Expanding on this topic: https://forum.elixirforum.net/t/map-typespec-question/19217 Let’s say I have a map with required and optional k...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New

Other popular topics Top

9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
yurko
Here are few pieces of (common) Linux knowledge that we use for reasonably small one server apps. We use Ubuntu but this should work for ...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New

We're in Beta

About us Mission Statement