AshFormBuilder.Info (AshFormBuilder v0.4.0)

View Source

Introspection helpers for AshFormBuilder DSL data.

As of v0.4 the DSL supports one form declaration per Ash action. All accessors take the action atom so callers can pick the right form config.

Works on both compiled resource modules and in-progress dsl_state maps (the latter is used inside Spark transformers).

Auto-inference

effective_fields/2 and effective_entities/2 are the preferred runtime accessors. They merge auto-inferred fields (derived from the action's accept list via AshFormBuilder.Infer) with any explicit DSL overrides. Explicit declarations win on a per-field basis.

The lower-level form_fields/2 and form_entities/2 return only the explicitly declared DSL entities.

Summary

Functions

Builds the AshPhoenix.Form :forms keyword list for the given action.

Returns all effective form entities: effective_fields/2 followed by the NestedForm structs declared for the action.

Returns the effective list of Field structs for the given action.

Accent color atom for the action's form (default :indigo).

Fetch the FormConfig for the given action, or nil.

All DSL entities (fields + nested forms) for the given action.

Only the top-level Field structs declared for the given action.

HTML id for the given action's form, or nil.

List of fields/nested-form names to suppress, declared via ignore_fields on the form.

Override module name for the generated form helper, or nil.

Only the NestedForm structs declared for the given action.

Submit label for the given action's form, defaults to "Submit".

Theme module for the action's form.

Transition intensity for the action's form (:none | :subtle | :smooth).

Wrapper CSS class for the given action's form.

All declared form configs in the order written.

True when the resource declares a form for the given action.

Functions

build_nested_forms_config(resource_or_dsl, action)

Builds the AshPhoenix.Form :forms keyword list for the given action.

effective_entities(resource, action)

@spec effective_entities(module(), atom()) :: list()

Returns all effective form entities: effective_fields/2 followed by the NestedForm structs declared for the action.

For zero-config use, a bare nested :foo do end block (no field children) auto-inflates with fields inferred from the destination resource's create action — so users get a fully wired sub-form for has_many relationships without writing any field declarations.

effective_fields(resource, action)

@spec effective_fields(module(), atom()) :: [AshFormBuilder.Field.t()]

Returns the effective list of Field structs for the given action.

Fields are produced by auto-inferring from the action's accept list (falling back to writable attributes when accept is empty), then applying explicit DSL declarations as overrides.

Any DSL field whose name is not in the inferred list is appended at the end, allowing argument fields not in accept.

form_accent(resource_or_dsl, action)

Accent color atom for the action's form (default :indigo).

form_config(resource_or_dsl, action)

@spec form_config(module() | map(), atom()) :: AshFormBuilder.FormConfig.t() | nil

Fetch the FormConfig for the given action, or nil.

form_entities(resource_or_dsl, action)

All DSL entities (fields + nested forms) for the given action.

form_fields(resource_or_dsl, action)

Only the top-level Field structs declared for the given action.

form_html_id(resource_or_dsl, action)

HTML id for the given action's form, or nil.

form_ignore_fields(resource_or_dsl, action)

List of fields/nested-form names to suppress, declared via ignore_fields on the form.

form_module_override(resource_or_dsl, action)

Override module name for the generated form helper, or nil.

form_nested(resource_or_dsl, action)

Only the NestedForm structs declared for the given action.

form_submit_label(resource_or_dsl, action)

Submit label for the given action's form, defaults to "Submit".

form_theme(resource_or_dsl, action)

Theme module for the action's form.

Resolves in this order:

  1. The form's theme: DSL value (atom or module — looked up in AshFormBuilder.Themes).
  2. The :theme Application env (atom or module — same lookup).
  3. AshFormBuilder.Themes.Default.

form_transitions(resource_or_dsl, action)

Transition intensity for the action's form (:none | :subtle | :smooth).

form_wrapper_class(resource_or_dsl, action)

Wrapper CSS class for the given action's form.

forms(resource_or_dsl)

@spec forms(module() | map()) :: [AshFormBuilder.FormConfig.t()]

All declared form configs in the order written.

has_form?(resource_or_dsl, action)

True when the resource declares a form for the given action.