Last active
March 17, 2016 10:54
-
-
Save stevedomin/abcdf4a41b00b6e6e981 to your computer and use it in GitHub Desktop.
Phoenix example form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= form_for @changeset, @action, fn f -> %> | |
<div> | |
<%= label f, :name %> | |
<%= text_input f, :name %> | |
</div> | |
<div> | |
<%= submit "Submit" %> | |
</div> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= render "form.html", changeset: @changeset, | |
action: user_path(@conn, :create, @user) %> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule HelloApp.User do | |
use HelloApp.Web, :controller | |
def new(conn, _params) do | |
changeset = HelloApp.User.changeset(%HelloApp.User{}) | |
render(conn, "new.html", changeset: changeset) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a minimal example to show how to create a reusable form template. The
create
action in the controller has been left out purposefully.