# AdaptableFormField

Canonical page: https://www.adaptabletools.com/docs/reference/adaptableformfield

Defines a Field that appears in an Adaptable Form

```ts title="TypeScript"
export interface AdaptableFormField 
```

## Properties

| Property | Type | Description | Default |
| --- | --- | --- | --- |
| [clearToDefault](https://www.adaptabletools.com/docs/reference/adaptableformfield.md#cleartodefault) | `boolean` | For single `select` fields only. When the user clears the combobox,<br/>whether to restore  instead of leaving the field empty.<br/><br/>Defaults to `true` when `defaultValue` is set, otherwise `false`.<br/>Set to `false` when an empty selection is a distinct state from the default. |   |
| [defaultValue](https://www.adaptabletools.com/docs/reference/adaptableformfield.md#defaultvalue) | `string \| boolean \| number \| Array<string \| number \| boolean>` | Field Default Value - can be of type string, boolean, number, or for<br/>`select` fields with `multi: true` an array of those.<br/><br/>For single `select` fields, this is also the value restored when the user<br/>clears the combobox (unless  is `false`). |   |
| [disabled](https://www.adaptabletools.com/docs/reference/adaptableformfield.md#disabled) | `boolean \| ((formData: `[`AdaptableFormData`](https://www.adaptabletools.com/docs/reference/adaptableformdata.md)`, context: `[`BaseContext`](https://www.adaptabletools.com/docs/reference/basecontext.md)`) => boolean)` | Disable the field&#39;s input. Either a boolean or a function evaluated<br/>against the current form data. Disabled fields render but the user<br/>cannot edit them. |   |
| [fieldType](https://www.adaptabletools.com/docs/reference/adaptableformfield.md#fieldtype) | [`AdaptableFormFieldType`](https://www.adaptabletools.com/docs/reference/adaptableformfieldtype.md) | Field Type - dictates which UI control is rendered |   |
| [helpText](https://www.adaptabletools.com/docs/reference/adaptableformfield.md#helptext) | `string` | Inline help text rendered immediately below the field&#39;s input. Useful<br/>for short explanations such as &quot;format: YYYY-MM-DD&quot; or &quot;min 3 chars&quot;. |   |
| [hidden](https://www.adaptabletools.com/docs/reference/adaptableformfield.md#hidden) | `boolean \| ((formData: `[`AdaptableFormData`](https://www.adaptabletools.com/docs/reference/adaptableformdata.md)`, context: `[`BaseContext`](https://www.adaptabletools.com/docs/reference/basecontext.md)`) => boolean)` | Hide the field. Either a boolean or a function evaluated against the<br/>current form data. Hidden fields are not rendered and are excluded from<br/>validation. |   |
| [label](https://www.adaptabletools.com/docs/reference/adaptableformfield.md#label) | `string` | Label to display in the Field |   |
| [max](https://www.adaptabletools.com/docs/reference/adaptableformfield.md#max) | `number \| string` | Maximum allowed value. For `number` and `slider`: the highest accepted<br/>number. For `date`, `time` and `datetime`: the latest allowed value in<br/>ISO format. |   |
| [maxLength](https://www.adaptabletools.com/docs/reference/adaptableformfield.md#maxlength) | `number` | Maximum length for `text` and `textarea` fields. |   |
| [min](https://www.adaptabletools.com/docs/reference/adaptableformfield.md#min) | `number \| string` | Minimum allowed value. For `number` and `slider`: the lowest accepted<br/>number. For `date`, `time` and `datetime`: the earliest allowed value<br/>in ISO format (`YYYY-MM-DD` / `HH:mm` / `YYYY-MM-DDTHH:mm`). |   |
| [minLength](https://www.adaptabletools.com/docs/reference/adaptableformfield.md#minlength) | `number` | Minimum length for `text` and `textarea` fields. |   |
| [multi](https://www.adaptabletools.com/docs/reference/adaptableformfield.md#multi) | `boolean` | For `select` fields only. When `true` the field renders as a<br/>multi-select combobox; the field&#39;s value is an array of selected<br/>`option.value`s rather than a single value. | false |
| [name](https://www.adaptabletools.com/docs/reference/adaptableformfield.md#name) | `string` | Name of the Field |   |
| [onValueChange](https://www.adaptabletools.com/docs/reference/adaptableformfield.md#onvaluechange) | `(value: any, context: `[`BaseContext`](https://www.adaptabletools.com/docs/reference/basecontext.md)`) => void` | Optional callback invoked whenever value of this field changes |   |
| [options](https://www.adaptabletools.com/docs/reference/adaptableformfield.md#options) | [`AdaptableFormFieldOption`](https://www.adaptabletools.com/docs/reference/adaptableformfieldoption.md)`[] \| ((formData: `[`AdaptableFormData`](https://www.adaptabletools.com/docs/reference/adaptableformdata.md)`, context: `[`BaseContext`](https://www.adaptabletools.com/docs/reference/basecontext.md)`) => `[`AdaptableFormFieldOption`](https://www.adaptabletools.com/docs/reference/adaptableformfieldoption.md)`[] \| Promise<`[`AdaptableFormFieldOption`](https://www.adaptabletools.com/docs/reference/adaptableformfieldoption.md)`[]>)` | Items to populate the `select` and `radio` fieldTypes.<br/><br/>Either a static array, or a function that derives the options from the<br/>current form data and Adaptable context. The function form may return<br/>a Promise for asynchronously-loaded options - the form will render the<br/>field with no items until the promise resolves. |   |
| [pattern](https://www.adaptabletools.com/docs/reference/adaptableformfield.md#pattern) | `string` | Regular expression that the value of a `text` field must match. |   |
| [placeholder](https://www.adaptabletools.com/docs/reference/adaptableformfield.md#placeholder) | `string` | Placeholder text shown inside `text`, `textarea`, `number`, `date`,<br/>`time` and `datetime` inputs when empty. For `select` fields it is<br/>rendered as the empty-state label when no value is selected.<br/><br/>When omitted on a `select` field with a , the label of<br/>the matching `options` entry is used as the empty-state label. |   |
| [render](https://www.adaptabletools.com/docs/reference/adaptableformfield.md#render) | `(params: `[`AdaptableFormFieldRenderParams`](https://www.adaptabletools.com/docs/reference/adaptableformfieldrenderparams.md)`) => React.ReactNode` | For `custom` fields only. Renders an arbitrary React node as the<br/>field&#39;s input. Receives the current value, a `setValue` setter<br/>(controlled), the current form data, the Adaptable context and the<br/>resolved `disabled` state.<br/><br/>Use this as an escape hatch when none of the built-in `fieldType`s<br/>fit - e.g. to render a star-rating widget, a tag editor or any<br/>bespoke control. |   |
| [required](https://www.adaptabletools.com/docs/reference/adaptableformfield.md#required) | `boolean` | If `true` the field is treated as required. An empty value (`''`,<br/>`null`, `undefined`, or unchecked checkbox) will produce a validation<br/>error. |   |
| [rows](https://www.adaptabletools.com/docs/reference/adaptableformfield.md#rows) | `number` | For `textarea` fields: the visible number of text rows. | 3 |
| [step](https://www.adaptabletools.com/docs/reference/adaptableformfield.md#step) | `number` | Stepping interval for `number`, `slider`, `time` and `datetime`<br/>fields. |   |
| [tooltip](https://www.adaptabletools.com/docs/reference/adaptableformfield.md#tooltip) | `string` | Tooltip shown when hovering the field&#39;s label. |   |
| [validate](https://www.adaptabletools.com/docs/reference/adaptableformfield.md#validate) | `(value: any, formData: `[`AdaptableFormData`](https://www.adaptabletools.com/docs/reference/adaptableformdata.md)`, context: `[`BaseContext`](https://www.adaptabletools.com/docs/reference/basecontext.md)`) => string \| null \| undefined` | Custom field-level validation. Return an error message string to mark<br/>the field invalid, or `null`/`undefined` if the value is valid.<br/><br/>Custom validation runs *after* built-in checks (`required`, `min`,<br/>`max`, `pattern`, etc.) - the first failing check wins. |   |

## Property Details

### clearToDefault

For single `select` fields only. When the user clears the combobox,
whether to restore  instead of leaving the field empty.

Defaults to `true` when `defaultValue` is set, otherwise `false`.
Set to `false` when an empty selection is a distinct state from the default.

```ts title="TypeScript"
clearToDefault?: boolean;
```

###### Property Value

`boolean`

### defaultValue

Field Default Value - can be of type string, boolean, number, or for
`select` fields with `multi: true` an array of those.

For single `select` fields, this is also the value restored when the user
clears the combobox (unless  is `false`).

```ts title="TypeScript"
defaultValue?: string | boolean | number | Array<string | number | boolean>;
```

###### Property Value

`string | boolean | number | Array<string | number | boolean>`

### disabled

Disable the field&#39;s input. Either a boolean or a function evaluated
against the current form data. Disabled fields render but the user
cannot edit them.

```ts title="TypeScript"
disabled?: boolean | ((formData: AdaptableFormData, context: BaseContext) => boolean);
```

###### Property Value

`boolean | ((formData: `[`AdaptableFormData`](https://www.adaptabletools.com/docs/reference/adaptableformdata.md)`, context: `[`BaseContext`](https://www.adaptabletools.com/docs/reference/basecontext.md)`) => boolean)`

### fieldType

Field Type - dictates which UI control is rendered

```ts title="TypeScript"
fieldType: AdaptableFormFieldType;
```

###### Property Value

[`AdaptableFormFieldType`](https://www.adaptabletools.com/docs/reference/adaptableformfieldtype.md)

### helpText

Inline help text rendered immediately below the field&#39;s input. Useful
for short explanations such as &quot;format: YYYY-MM-DD&quot; or &quot;min 3 chars&quot;.

```ts title="TypeScript"
helpText?: string;
```

###### Property Value

`string`

### hidden

Hide the field. Either a boolean or a function evaluated against the
current form data. Hidden fields are not rendered and are excluded from
validation.

```ts title="TypeScript"
hidden?: boolean | ((formData: AdaptableFormData, context: BaseContext) => boolean);
```

###### Property Value

`boolean | ((formData: `[`AdaptableFormData`](https://www.adaptabletools.com/docs/reference/adaptableformdata.md)`, context: `[`BaseContext`](https://www.adaptabletools.com/docs/reference/basecontext.md)`) => boolean)`

### label

Label to display in the Field

```ts title="TypeScript"
label: string;
```

###### Property Value

`string`

### max

Maximum allowed value. For `number` and `slider`: the highest accepted
number. For `date`, `time` and `datetime`: the latest allowed value in
ISO format.

```ts title="TypeScript"
max?: number | string;
```

###### Property Value

`number | string`

### maxLength

Maximum length for `text` and `textarea` fields.

```ts title="TypeScript"
maxLength?: number;
```

###### Property Value

`number`

### min

Minimum allowed value. For `number` and `slider`: the lowest accepted
number. For `date`, `time` and `datetime`: the earliest allowed value
in ISO format (`YYYY-MM-DD` / `HH:mm` / `YYYY-MM-DDTHH:mm`).

```ts title="TypeScript"
min?: number | string;
```

###### Property Value

`number | string`

### minLength

Minimum length for `text` and `textarea` fields.

```ts title="TypeScript"
minLength?: number;
```

###### Property Value

`number`

### multi

For `select` fields only. When `true` the field renders as a
multi-select combobox; the field&#39;s value is an array of selected
`option.value`s rather than a single value.

```ts title="TypeScript"
multi?: boolean;
```

###### Default Value

false

###### Property Value

`boolean`

### name

Name of the Field

```ts title="TypeScript"
name: string;
```

###### Property Value

`string`

### onValueChange

Optional callback invoked whenever value of this field changes

```ts title="TypeScript"
onValueChange?: (value: any, context: BaseContext) => void;
```

###### Property Value

`(value: any, context: `[`BaseContext`](https://www.adaptabletools.com/docs/reference/basecontext.md)`) => void`

### options

Items to populate the `select` and `radio` fieldTypes.

Either a static array, or a function that derives the options from the
current form data and Adaptable context. The function form may return
a Promise for asynchronously-loaded options - the form will render the
field with no items until the promise resolves.

```ts title="TypeScript"
options?: AdaptableFormFieldOption[] | ((formData: AdaptableFormData, context: BaseContext) => AdaptableFormFieldOption[] | Promise<AdaptableFormFieldOption[]>);
```

###### Property Value

[`AdaptableFormFieldOption`](https://www.adaptabletools.com/docs/reference/adaptableformfieldoption.md)`[] | ((formData: `[`AdaptableFormData`](https://www.adaptabletools.com/docs/reference/adaptableformdata.md)`, context: `[`BaseContext`](https://www.adaptabletools.com/docs/reference/basecontext.md)`) => `[`AdaptableFormFieldOption`](https://www.adaptabletools.com/docs/reference/adaptableformfieldoption.md)`[] | Promise<`[`AdaptableFormFieldOption`](https://www.adaptabletools.com/docs/reference/adaptableformfieldoption.md)`[]>)`

### pattern

Regular expression that the value of a `text` field must match.

```ts title="TypeScript"
pattern?: string;
```

###### Property Value

`string`

### placeholder

Placeholder text shown inside `text`, `textarea`, `number`, `date`,
`time` and `datetime` inputs when empty. For `select` fields it is
rendered as the empty-state label when no value is selected.

When omitted on a `select` field with a , the label of
the matching `options` entry is used as the empty-state label.

```ts title="TypeScript"
placeholder?: string;
```

###### Property Value

`string`

### render

For `custom` fields only. Renders an arbitrary React node as the
field&#39;s input. Receives the current value, a `setValue` setter
(controlled), the current form data, the Adaptable context and the
resolved `disabled` state.

Use this as an escape hatch when none of the built-in `fieldType`s
fit - e.g. to render a star-rating widget, a tag editor or any
bespoke control.

```ts title="TypeScript"
render?: (params: AdaptableFormFieldRenderParams) => React.ReactNode;
```

###### Property Value

`(params: `[`AdaptableFormFieldRenderParams`](https://www.adaptabletools.com/docs/reference/adaptableformfieldrenderparams.md)`) => React.ReactNode`

### required

If `true` the field is treated as required. An empty value (`''`,
`null`, `undefined`, or unchecked checkbox) will produce a validation
error.

```ts title="TypeScript"
required?: boolean;
```

###### Property Value

`boolean`

### rows

For `textarea` fields: the visible number of text rows.

```ts title="TypeScript"
rows?: number;
```

###### Default Value

3

###### Property Value

`number`

### step

Stepping interval for `number`, `slider`, `time` and `datetime`
fields.

```ts title="TypeScript"
step?: number;
```

###### Property Value

`number`

### tooltip

Tooltip shown when hovering the field&#39;s label.

```ts title="TypeScript"
tooltip?: string;
```

###### Property Value

`string`

### validate

Custom field-level validation. Return an error message string to mark
the field invalid, or `null`/`undefined` if the value is valid.

Custom validation runs *after* built-in checks (`required`, `min`,
`max`, `pattern`, etc.) - the first failing check wins.

```ts title="TypeScript"
validate?: (value: any, formData: AdaptableFormData, context: BaseContext) => string | null | undefined;
```

###### Property Value

`(value: any, formData: `[`AdaptableFormData`](https://www.adaptabletools.com/docs/reference/adaptableformdata.md)`, context: `[`BaseContext`](https://www.adaptabletools.com/docs/reference/basecontext.md)`) => string | null | undefined`
