links: Phoenix MOC


Phoenix HTML Form

You can create forms in three ways

Using changeset:

The changeset comes from the Ecto.changeset

<%= form_for @changeset, "/register", fn f -> %>
	<%= label f, :email %>
	<%= email_input f, :email, placeholder: "example@email.com" %>
	<%= error_tag f, :email %>
	<%= submit "Submit" %>
<% end %>

With limited data:

<%= form_for @conn, "/login", fn f -> %>
	<%= text_input f, :search %>
	<%= submit "Search" %>
<% end %>

Without Form data:

<%= text_input :user, :name, value: "This is a populated value" %>

tags: html, form, phoenix

source: