FormBuilderDSL.DSL (form_builder_dsl v0.1.2)
View SourceThe core DSL module that provides form building capabilities.
This module provides macros for defining form fields, enums, and form structure. It handles the compilation of form definitions into metadata structures that can be used for rendering, validation, and serialization.
Summary
Functions
Returns the list of fields defined in the form.
Defines an enum with the given name and values.
Defines a form with the given name and block of field definitions.
Converts an atom to a human-readable string.
Defines a text input field.
Types
Functions
Returns the list of fields defined in the form.
Defines an enum with the given name and values.
Parameters
name
- The atom name for the enumvalues
- List of atom values for the enum
Example
defenum :status, [:active, :inactive]
This will generate:
status_options/0
- Returns list of string valuesstatus_labeled_options/0
- Returns list of {label, value} tuples
Defines a form with the given name and block of field definitions.
Parameters
name
- The atom name for the formblock
- A block containing field definitions
Example
form :user do
text :name
email(:email)
end
Converts an atom to a human-readable string.
Parameters
atom
- The atom to convert
Returns
- A capitalized string with underscores replaced by spaces
Example
iex> FormBuilderDSL.DSL.humanize(:first_name)
"First name"
Defines a text input field.
Parameters
key
- The atom key for the fieldopts
- Optional field attributes
Options
:label
- Custom label for the field:required
- Whether the field is required:placeholder
- Placeholder text:default
- Default value:validations
- List of validation rules:disabled
- Whether the field is disabled