I put a simple_form
inside a core modal
component.
- Is it possible to submit the form using the modal
:confirm
slot? - When the form is submitted a record is created, how can I close the modal when the opration is successful?
Here is the code execute when the form is submitted:
@impl true
def handle_event("save", %{"user" => params}, socket) do
case Accounts.create_user_with_roles(params, []) do
{:ok, _} ->
{:noreply,
socket
|> put_flash(:success, dgettext("admin", "User created succesfully"))
|> ... here I would like to just close the modal and show the flash ...
}
{:error, changeset} ->
{:noreply, assign(socket, form: to_form(changeset))}
end
end
Cheers!