AshFormBuilder.TypeInference (AshFormBuilder v0.2.0)

View Source

Infers AshFormBuilder.Field structs from an Ash resource action at runtime.

DEPRECATED: This module is kept for backward compatibility. Please use AshFormBuilder.Infer for new code.

Called by AshFormBuilder.Info.effective_fields/1 to produce auto-inferred fields for any attribute in the action's accept list or arguments list that does not already have an explicit DSL override.

Relationship Support

Now delegates to AshFormBuilder.Infer which supports:

  • Auto-detection of many_to_many relationships
  • Mapping many_to_many to :multiselect_combobox UI type
  • Full relationship metadata in inferred fields

Summary

Functions

Returns inferred Field structs for the given resource action.

Infers a field from a single argument (backward compatibility).

Infers a field from a single attribute (backward compatibility).

Functions

infer_fields(resource, action_name)

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

Returns inferred Field structs for the given resource action.

Fields are produced in the order they appear in action.accept, followed by action arguments (if any).

Relationship Detection

When the action's accept list includes relationship names:

  • many_to_many relationships are mapped to :multiselect_combobox type
  • Relationship metadata (relationship, relationship_type, destination_resource) is populated on the field struct

infer_from_argument(arg)

@spec infer_from_argument(Ash.Resource.Actions.Argument.t()) ::
  AshFormBuilder.Field.t()

Infers a field from a single argument (backward compatibility).

infer_from_attribute(attr)

@spec infer_from_attribute(Ash.Resource.Attribute.t()) :: AshFormBuilder.Field.t()

Infers a field from a single attribute (backward compatibility).