FormElement

API / @publicodes/forms / FormElement

type FormElement<Name> = 
  | InputElement<Name, InputType>
  | SelectElement<Name>
  | RadioGroupElement<Name>
| TextareaElement<Name>;

Defined in: formElement.ts:97

Represents the different types of form elements that can be generated from Publicodes rules. This union type combines all possible form control representations.

Type Parameters

Type ParameterDefault type
Name extends stringstring

Example

// Input element for a number
const salaryInput: FormElement = {
  element: 'input',
  type: 'number',
  label: 'Salary',
  id: 'employee.salary'
}

// Radio group for a boolean choice
const activeInput: FormElement = {
  element: 'RadioGroup',
  style: 'button',
  orientation: 'horizontal',
  options: [
    { label: 'Yes', value: true },
    { label: 'No', value: false }
  ],
  label: 'Is active?',
  id: 'employee.active'
}

See

getFormElement