FormBuilderDSL

A clean, minimal, and extensible DSL for defining structured, dynamic forms in Elixir.

FormBuilderDSL helps teams write intuitive, maintainable forms with metadata structures that can power:


โœจ Features


๐Ÿงช Example

defmodule MyForm do
use FormBuilderDSL
defenum :status, [:approved, :rejected, :pending]
form :user do
text :name
select :status, options: status_labeled_options()
end
end
[
%FormBuilderDSL.Field{
key: :status,
label: "Status",
placeholder: false,
type: :select,
options: [
{"Approved", "approved"},
{"Rejected", "rejected"},
{"Pending", "pending"}
],
required: false,
default: false,
validations: false,
disabled: false
},
%FormBuilderDSL.Field{
key: :id,
label: "Id",
placeholder: false,
type: :text,
options: [],
required: false,
default: false,
validations: false,
disabled: false
}
]

๐Ÿ“ฆ Installation

Add the dependency to your mix.exs:

def deps do
[
{:form_builder_dsl, "~> 0.1.0"}
]
end

Then run:

mix deps.get

๐Ÿ›  Optional: Add Formatter Settings

To keep the DSL syntax clean and bracket-free, add the following to your .formatter.exs:

[
import_deps: [:form_builder_dsl],
locals_without_parens: [
form: 2,
defenum: 2,
text: 1,
text: 2,
select: 1,
select: 2,
date_time: 1,
date_time: 2
]
]

This tells the formatter not to wrap parentheses around common DSL macros.


๐Ÿ“„ License

MIT ยฉ Pranav J