Phoenix.HTML.FormData protocol

Converts a data structure into a Phoenix.HTML.Form struct.

Source

Summary

input_type(data, field)

Receives the given field and returns its input type (:text_input, :select, etc). Returns nil if the type is unknown

input_validations(data, field)

Returns the HTML5 validations that would apply to the given field

to_form(data, options)

Converts a data structure into a Phoenix.HTML.Form struct

to_form(data, form, field, options)

Converts the field in the given form based on the data structure into a Phoenix.HTML.Form struct

Types

t :: term

Functions

input_type(data, field)

Specs:

  • input_type(t, atom) :: atom | nil

Receives the given field and returns its input type (:text_input, :select, etc). Returns nil if the type is unknown.

Source
input_validations(data, field)

Specs:

Returns the HTML5 validations that would apply to the given field.

Source
to_form(data, options)

Specs:

Converts a data structure into a Phoenix.HTML.Form struct.

The options are the same options given to form_for/4. It can be used by implementations to configure their behaviour and it must be stored in the underlying struct, with any custom field removed.

Source
to_form(data, form, field, options)

Specs:

Converts the field in the given form based on the data structure into a Phoenix.HTML.Form struct.

The options are the same options given to inputs_for/4. It can be used by implementations to configure their behaviour and it must be stored in the underlying struct, with any custom field removed.

Source