- Typed schema
FormSchema.For<Order>(s => { s.Field(o => o.Seats, f => f.Range(1, 500)); ... }) declares fields from the members of a C# class and returns a handle per field, so a condition points at an earlier field through a captured local and controller.Get(seats) is an int. Kind-specific settings (AsTextarea, Range, Options, AsSwitch) are extension methods constrained on the type of the value, so a wrong kind does not compile. Group, List, MultiSelect, Step and Section declare nested objects, repeatable rows, multiple choice, wizards and pages.- Headless controller
FormController<TModel> manages values, touched state, errors, dirty tracking, steps and submission with no UI dependency, and Klyroo.Form.Core is NativeAOT compatible.- Typed components
KlyFormEngine<TModel> and KlyFormPage<TModel> render a FormSchema<TModel> (or a FormController<TModel>) with a Model, and infer TModel from the markup. OnSave receives the model, OnSubmit is raised with it, and a submit writes the values into the model you gave, all or nothing. KlyFormFieldView draws one field for a layout of your own, and KlyFieldTemplate draws the control of one field with a typed FormControlContext<TValue>.- Validation
- Required and required-when checks, number bounds, password requirements, typed
Rule and RuleAsync rules with a pending state (debounced, stale runs cancelled, awaited by submit), four validation modes and three triggers (blur, input, submit). - Model binding that cannot lose data
- Values move between the form and the model with culture-independent conversions (a
long, a decimal and a double keep every digit), a write into a model is all or nothing and rolls back when the save fails, and a value the user did not change keeps its ticks, kind and offset. Klyroo.Form.DataAnnotations reads [Required], [Range], [Display] and the other attributes into a typed schema, and runs IValidatableObject at submit. - Server errors
SetError attaches a message to a field, optionally blocking submission until the user edits it.- Conditional fields
VisibleWhen, Required(condition), DisabledWhen and skipWhen are plain delegates evaluated against the controller, and hidden fields, the children of hidden containers and the fields of skipped steps are left out of validation and of the model.- Dirty tracking
- The controller compares values with an initial snapshot, resets a field or a section, and takes a new snapshot after a successful submit.
- Wizards and pages
- Multi-step forms with skippable steps and async before-next hooks, and sectioned pages that show a completion status per section.
- Extensible
KlyFieldTemplate swaps the control of a typed field for your markup, AsCustom(key) plus CustomField<TValue>(key, renderer) registers one for the whole app, and FormFileValue fields are checked for Accept, MaxFileSize and multiple files in the core.- Localization
- The built-in texts and validation messages follow the Klyroo.UI locale in twelve languages (English and French reviewed, the rest drafts),
AddKlyrooForm(f => f.Texts("fr", t => t with { ... })) changes them, and FormMessages works without Blazor. - Unsaved changes
KlyFormNavigationGuard blocks navigation while the form is dirty, and ExportDraft() and RestoreDraft() keep a draft across a reload with the original baseline, so the restored draft is still dirty.- Overlays
FormService.CreateFormAsync<TModel> opens a form in a modal dialog, a side drawer or a fullscreen view hosted by KlyFormProvider (on KlyModal and KlySlideover: focus trap, Escape, focus restored) and returns the result as a task (FormSubmitOutcome<TModel> with the submitted model).- Agent ready
FormController<TModel> (like the runtime DynamicFormController) implements IFormRuntime, which lists the fields as IFormFieldAccess with JSON read and write (numbers keep their exact digits, a choice matches by value or label), so an agent bridge drives a form without knowing its model type.- Runtime mode
- When the fields are only known at runtime,
DynamicFormSchema and DynamicFieldSchema (namespace Klyroo.Form.Dynamic) describe the form as data, with values keyed by name, on the same engine. FormFieldKind has 33 values, and KlyDynamicFormEngine and KlyDynamicFormPage render each one. See Forms defined at runtime.