AshFormBuilder.FormRenderer (AshFormBuilder v0.4.0)

View Source

Phoenix function components that render form entities.

Structural rendering (entity iteration, nested inputs_for loops, add/remove buttons) lives here. Per-field widget rendering is delegated to a theme module.

The theme is resolved in this order:

  1. The :theme assign passed to form_fields/1 (preferred — set by AshFormBuilder.FormComponent from the per-form DSL).
  2. The :ash_form_builder, :theme Application config.
  3. AshFormBuilder.Themes.Default.

Summary

Functions

Renders all entities (fields and nested forms) for a form.

Renders a nested relationship form block with add/remove buttons.

Functions

form_fields(assigns)

Renders all entities (fields and nested forms) for a form.

Required assigns:

  • :formPhoenix.HTML.Form
  • :entities — list of Field and NestedForm structs
  • :target — LiveComponent target (@myself)
  • :wrapper_class — CSS class for the wrapper div

Optional:

  • :theme — theme module (overrides Application env)
  • :theme_opts — keyword list of theme-specific options (:accent, :transitions, etc.)
  • :uploads — LiveView upload configs map

Attributes

  • form (Phoenix.HTML.Form) (required)
  • entities (:list) (required)
  • target (:any) - Defaults to nil.
  • wrapper_class (:string) - Defaults to "space-y-4".
  • theme (:atom) - Defaults to nil.
  • theme_opts (:list) - Defaults to [].
  • uploads (:map) - Defaults to %{}.

nested_form(assigns)

Renders a nested relationship form block with add/remove buttons.

Attributes

  • form (Phoenix.HTML.Form) (required)
  • nested (:any) (required)
  • target (:any) - Defaults to nil.
  • theme (:atom) - Defaults to nil.
  • theme_opts (:list) - Defaults to [].