I tried to receive this in my handle_event like I have shown below, but no luck. Is this possible to do with select input? I know this is possible with button clicks?
Support for phx-change on individual inputs has been added at some point as well, which is described a few paragraphs later to where your documentation example came from.
Just to give a bit more info, I am trying to update some values on the changeset based on the index. For example - I have a list of “items” which are maps, and I want to edit few attributes of one of these items based on the index
I just saw this: You won’t get multiple maps. At best you’d get one map with both values in it. The callback is of arity-3: event-name, some metadata, socket.
You should be able to figure out which input is the source of the change event by inspecting the _target property passed by LiveView in the parameters (the second argument given to handle_event). That property contains the path to the input that triggered the change.
_target only shows which element. It does not give the index. This is a “Add one more” situation in a form. And based on a “select” input, I need to set a attribute in the changeset to nil, but to do that, need to figure out exactly which index I need to modify in the list since its a list of maps
I got the above result when I had the |name: “licensed_officially”| attribute in my form select. Once I removed it, I was able to get the index and a whole lot more information through the _target!