Phlex form builder

Forms that already know your model

phlex-forms renders label, input, and error in one field call — type, requiredness, and choices inferred from the model. Declare forms as Phlex classes, theme them daisyUI or plain, and validate live against the real validators.

Gemfile
gem "phlex-forms"
Model-driven inference

field :notify renders a toggle for a boolean column, an enum becomes a humanized select, a belongs_to a collection select — as:/choices: are overrides, not requirements.

Forms as classes

Subclass Forms::Base and declare fields where self IS the form — reusable, testable form objects with inherited defaults, no f. prefix on every line.

Live server-truth validation

live model: User runs your REAL validators on blur — uniqueness, :if/:unless, confirmation — and morphs errors back with focus preserved, via phlex-reactive.

daisyUI or plain

Variants stack positionally (field :email, :primary, :sm) with form-level defaults; swap the theme and the same form class renders bare semantic HTML in a non-daisyUI project.

Client-side fallback

No phlex-reactive? validate: true mirrors your ActiveModel validators into shipped Stimulus controllers — presence, length counters, format, confirmation, and more.

Migration-ready

Rails-parity helpers (fields_for, collection_check_boxes), unscoped and JSONB modes for dynamic rows, and RuboCop cops that autocorrect legacy form calls.