FormElement

API / @publicodes/forms / FormElement

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

Defined in: formElement.ts:92

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

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