Skip to content

Instantly share code, notes, and snippets.

@tslim
Last active June 6, 2020 09:41
# in router
scope "/", MyApp do
...
live "/users/new", UserLive.Index, :new
live "/users/:id/edit", UserLive.Index, :edit
...
end
# in live/user_live/index.html.leex
<%= if @live_action in [:new, :edit] do %>
<%= live_modal @socket, MyApp.UserLive.FormComponent,
id: @user.id || :new,
title: @page_title,
action: @live_action,
user: @user,
return_to: Routes.user_index_path(@socket, :index) %>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment