MishkaGervaz.Form.Entities.NestedField (MishkaGervaz v0.0.1-alpha.2)

Copy Markdown View Source

Sub-field declaration inside a :nested form field — used for embedded resources and constrained {:array, :map} attributes.

Lets you customize each sub-field's type, required-ness, default, position, options, and UI without re-declaring the entire embedded shape. Sub-fields not explicitly declared are auto-detected when the parent field has auto_fields true.

Example

field :items, :nested do
  nested_field :name, :text do
    required true

    ui do
      label "Item name"
      placeholder "e.g. Widget"
    end
  end

  nested_field :count, :number do
    position :last

    ui do
      label "Quantity"
    end
  end
end

See MishkaGervaz.Form.Entities.Field for the parent field, MishkaGervaz.Form.Dsl.Fields for the surrounding DSL, and MishkaGervaz.Form.Entities.NestedField.Ui for the ui sub-entity.

Summary

Types

position()

@type position() :: integer() | :first | :last | {:before, atom()} | {:after, atom()}

t()

@type t() :: %MishkaGervaz.Form.Entities.NestedField{
  __identifier__: term(),
  __spark_metadata__: map() | nil,
  default: any(),
  name: atom(),
  options: list() | nil,
  position: position() | nil,
  readonly: boolean(),
  required: boolean() | nil,
  type: atom() | nil,
  ui: MishkaGervaz.Form.Entities.NestedField.Ui.t() | nil,
  visible: boolean()
}

Functions

transform(nested_field)