You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/Inputs.md
+3-3
Original file line number
Diff line number
Diff line change
@@ -142,7 +142,7 @@ form state value --> format --> form input value (string)
142
142
143
143
`format` often comes in pair with [`parse`](#parse) to transform the input value before storing it in the form state. See the [Transforming Input Value](#transforming-input-value-tofrom-record) section for more details.
144
144
145
-
**Tip:** By default, react-admin inputs have to following `format` function, which turns any `null` or `undefined` value into an empty string. This is to avoid warnings about controlled/uncontrolled input components:
145
+
**Tip:** By default, react-admin inputs have the following `format` function, which turns any `null` or `undefined` value into an empty string. This is to avoid warnings about controlled/uncontrolled input components:
146
146
147
147
```js
148
148
constdefaultFormat= (value:any) => value ==null?'': value;
@@ -221,7 +221,7 @@ form input value (string) ---> parse ---> form state value
221
221
222
222
`parse` often comes in pair with [`format`](#format) to transform the form value before passing it to the input. See the [Transforming Input Value](#transforming-input-value-tofrom-record) section for more details.
223
223
224
-
**Tip:** By default, react-admin inputs have to following `parse` function, which transforms any empty string into `null`:
224
+
**Tip:** By default, react-admin inputs have the following `parse` function, which transforms any empty string into `null`:
225
225
226
226
```js
227
227
constdefaultParse= (value:string) => value ===''?null: value;
**Tip:** A common usage for this feature is to deal with empty values. Indeed HTML form inputs always return strings, even for numbers and booleans, however most backends expect a value like `null`. This is why, by default, all react-admin inputs will store the value `null` when the HTML input value is `''`.
391
+
**Tip:** A common usage for this feature is to deal with empty values. Indeed, HTML form inputs always return strings, even for numbers and booleans, however most backends expect a value like `null`. This is why, by default, all react-admin inputs will store the value `null` when the HTML input value is `''`.
392
392
393
393
**Tip**: If you need to do this globally, including for custom input components that do not use [the `useInput` hook](#the-useinput-hook), have a look at [the `sanitizeEmptyValues` prop of the `<Form>` component](./Form.md#sanitizeemptyvalues).
0 commit comments