There’s nothing really special about form submission in a liveview. It’s just a websocket payload getting delivered to an event handler, exactly the same as any communication from the browser to the liveview. The only two minor differences are:
it is automatically wired up to any submit button associated with the form, and
the form parameters are passed into the handler. The mechanics of handling the event, redirecting etc are the same for any event.
So the main issue you have to deal with is not having the form parameters passed into the event handler for another button (in this case handle_event("add_thing", ..., socket)
If you already have a form change handler (e.g. phx-change="validate" - quite common if you have live validation), then you have the changeset to do what you would do on form submit, held in socket.assigns already.
If you don’t, and you don’t want one, your phx-value-xxx will need to contain some identifier that you can use to recreate what you need in the event handler.
I had to add a phx_change handler to the form, which sends the field request to the handle_event function, which writes a field request-id in the socket. This field will be inserted into the phi-value-requester-id variable. Now, if you click on the one the two buttons, the value requester-id can be handled in one of the functions add_requester or delete-requester.
Good to hear you have it going. As a possible refinement, you already have the id value in socket.assigns so you probably don’t need the phx-value-requester-Id in your template either - just ignore the event params and look the id up from socket.assigns.