Nested / embedded form field type, used for inputs_for and constrained-map columns.
Example
field :seo_tags, :nested do
ui do
add_label "+ Add SEO tag"
remove_label "Remove"
end
nested_field :tag do
ui do placeholder "meta, link, script" end
end
nested_field :content, :textarea do
ui do rows 3 end
end
endSub-field values are cast on the way in
parse_params/2 casts each row by its sub-field's declared type before the value reaches the
changeset:
| Sub-field type | Cast |
|---|---|
:checkbox, :toggle | "true" / "on" / "1" to true; "false" / "off" / "0" / "" to false |
:number | integer, then float |
:key_map | each declared key cast, then blanks dropped |
:key_list | each row cast and pruned, then empty rows dropped |
Anything it cannot make sense of is left exactly as it came, and a value that is already the right type passes through untouched.
See MishkaGervaz.Form.Behaviours.FieldType and MishkaGervaz.Form.Types.Field.