Form

Defines a form that lets the user submit information


Provides a wrapper for Phoenix.HTML.Form.form_for/3 . Additionally, adds the form instance that is returned by form_for/3 into the context, making it available to any child input.

All options passed via opts will be sent to form_for/3 , for and action can be set directly and will override anything in opts .


@user = {
  "email": "",
  "name": ""
}

<Form for={{ :user }} change="change" opts={{ autocomplete: "off" }}>
  <Field name="name">
    <Label/>
    <div class="control">
      <TextInput value={{ @user["name"] }}/>
    </div>
  </Field>
  <Field name="email" class="field">
    <Label>E-mail</Label>
    <div class="control">
      <TextInput value={{ @user["email"] }}/>
    </div>
  </Field>
</Form>

<pre>@user = {{ Jason.encode!(@user, pretty: true) }}</pre>

# Public API

Name Description Type Values Default
for Required. Atom or changeset to inform the form data.

:any
action URL to where the form is submitted.

:string "#"
opts Keyword list with options to be passed down to form_for/3 .

:keyword []