Skip to content

Commit

Permalink
showcase app: recreate form on change event
Browse files Browse the repository at this point in the history
  • Loading branch information
maxmarcon committed Dec 1, 2023
1 parent d957453 commit fea86c6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion lib/support/live_select_web/live/showcase_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ defmodule LiveSelectWeb.ShowcaseLive do
def mount(_params, _session, socket) do
socket =
assign(socket,
live_select_field: to_form(%{}, as: :my_form)[:city_search],
live_select_form: to_form(%{}, as: :my_form),
events: [],
next_event_id: 0,
locations: nil,
Expand Down Expand Up @@ -354,6 +354,9 @@ defmodule LiveSelectWeb.ShowcaseLive do

socket

"change" ->
assign(socket, :live_select_form, to_form(params["my_form"], as: :my_form))

_event ->
socket
end
Expand Down
4 changes: 2 additions & 2 deletions lib/support/live_select_web/live/showcase_live.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -275,15 +275,15 @@
</div>
<div class="md:w-3/4">
<.form
for={@live_select_field.form}
for={@live_select_form}
phx-change="change"
phx-submit="submit"
id="live-select-form"
>
<div class="grid grid-cols-4 gap-1">
<div class="col-span-3 form-control">
<.live_select
field={@live_select_field}
field={@live_select_form[:city_search]}
{live_select_assigns(@settings_form.source)}
/>
</div>
Expand Down

0 comments on commit fea86c6

Please sign in to comment.