Skip to content

Instantly share code, notes, and snippets.

@tslim
Last active June 6, 2020 09:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tslim/1bc56a1b0a641b304b3ec9f46962daad to your computer and use it in GitHub Desktop.
Save tslim/1bc56a1b0a641b304b3ec9f46962daad to your computer and use it in GitHub Desktop.
# 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