Skip to content

Commit

Permalink
Merge pull request #5239 from WiXSL/fix-react-final-form-links
Browse files Browse the repository at this point in the history
[Doc] Fix react-final-form links
  • Loading branch information
djhi authored Sep 9, 2020
2 parents ba1f5ef + 5257f4b commit dcb2a2e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ const PostFilter = props =>

## `<Form>` `defaultValue` Prop Was Renamed To `initialValues`

This is actually to be consistent with the underlying form library ([final-form](https://final-form.org/docs/react-final-form))
This is actually to be consistent with the underlying form library ([final-form](https://final-form.org/docs/react-final-form/getting-started))

```diff
// for SimpleForm
Expand Down
8 changes: 4 additions & 4 deletions docs/CreateEdit.md
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ This custom Edit view has no action buttons or aside component - it's up to you

The `<SimpleForm>` component receives the `record` as prop from its parent component. It is responsible for rendering the actual form. It is also responsible for validating the form data. Finally, it receives a `handleSubmit` function as prop, to be called with the updated record as an argument when the user submits the form.

The `<SimpleForm>` renders its child components line by line (within `<div>` components). It accepts Input and Field components as children. It relies on `react-final-form` for form handling.
The `<SimpleForm>` renders its child components line by line (within `<div>` components). It accepts Input and Field components as children. It relies on [react-final-form](https://github.com/final-form/react-final-form) for form handling.

![post edition form](./img/post-edition.png)

Expand Down Expand Up @@ -942,7 +942,7 @@ export const UserCreate = (props) => (
);
```

**Tip**: The props you pass to `<SimpleForm>` and `<TabbedForm>` are passed to the `<Form>` of `react-final-form`.
**Tip**: The props you pass to `<SimpleForm>` and `<TabbedForm>` are passed to the [<Form>](https://final-form.org/docs/react-final-form/api/Form) of `react-final-form`.

### Per Input Validation: Built-in Field Validators

Expand Down Expand Up @@ -1105,7 +1105,7 @@ export const ProductEdit = ({ ...props }) => (
```
{% endraw %}

**Tip**: The props of your Input components are passed to a `react-final-form` `<Field>` component.
**Tip**: The props of your Input components are passed to a `react-final-form` [<Field>](https://final-form.org/docs/react-final-form/api/Field) component.

**Tip**: You can use *both* Form validation and input validation.

Expand Down Expand Up @@ -1539,7 +1539,7 @@ const VisitorEdit = props => (
);
```

**Tip**: `FormWithRedirect` contains some logic that you may not want. In fact, nothing forbids you from using [a react-final-form `Form` component](https://final-form.org/docs/react-final-form/api/Form) as root component for a custom form layout. You'll have to set initial values based the injected `record` prop manually, as follows:
**Tip**: `FormWithRedirect` contains some logic that you may not want. In fact, nothing forbids you from using a react-final-form [Form](https://final-form.org/docs/react-final-form/api/Form) component as root component for a custom form layout. You'll have to set initial values based the injected `record` prop manually, as follows:

{% raw %}
```jsx
Expand Down
10 changes: 5 additions & 5 deletions docs/Inputs.md
Original file line number Diff line number Diff line change
Expand Up @@ -1423,7 +1423,7 @@ import { TextInput } from 'react-admin';

## Transforming Input Value to/from Record

The data format returned by the input component may not be what your API desires. Since React-admin uses react-final-form, we can use its [`parse()`](https://github.com/final-form/react-final-form#parse-value-any-name-string--any) and [`format()`](https://github.com/final-form/react-final-form#format-value-any-name-string--any) functions to transform the input value when saving to and loading from the record.
The data format returned by the input component may not be what your API desires. Since React-admin uses react-final-form, we can use its [`parse`](https://final-form.org/docs/react-final-form/types/FieldProps#parse) and [`format`](https://final-form.org/docs/react-final-form/types/FieldProps#format) functions to transform the input value when saving to and loading from the record.

Mnemonic for the two functions:

Expand Down Expand Up @@ -1582,7 +1582,7 @@ const LatLngInput = () => (

**Tip**: Material-ui's `<TextField>` component already includes a label, so you don't need to use `<Labeled>` in this case.

`useField()` returns two values: `input` and `meta`. To learn more about these props, please refer to [the `useField()` hook documentation](https://final-form.org/docs/react-final-form/api/useField) in the react-final-form website.
`useField()` returns two values: `input` and `meta`. To learn more about these props, please refer to the [`useField`](https://final-form.org/docs/react-final-form/api/useField) hook documentation in the react-final-form website.

Instead of HTML `input` elements or material-ui components, you can use react-admin input components, like `<NumberInput>` for instance. React-admin components already use `useField()`, and already include a label, so you don't need either `useField()` or `<Labeled>` when using them:

Expand Down Expand Up @@ -1686,7 +1686,7 @@ const PersonEdit = props => (

Edition forms often contain linked inputs, e.g. country and city (the choices of the latter depending on the value of the former).

React-admin relies on react-final-form, so you can grab the current form values using react-final-form [useFormState](https://github.com/final-form/react-final-form#useformstate) hook. Alternatively, you can use the react-admin `<FormDataConsumer>` component, which grabs the form values, and passes them to a child function.
React-admin relies on react-final-form, so you can grab the current form values using react-final-form [useFormState](https://final-form.org/docs/react-final-form/api/useFormState) hook. Alternatively, you can use the react-admin `<FormDataConsumer>` component, which grabs the form values, and passes them to a child function.

This facilitates the implementation of linked inputs:

Expand Down Expand Up @@ -1716,7 +1716,7 @@ const OrderEdit = (props) => (
- `scopedFormData`: an object containing the current values of the currently rendered item from the `ArrayInput`
- `getSource`: a function which will translate the source into a valid one for the `ArrayInput`

Would you need to update an input when another one changes, use the `useForm` hook from `react-final-form`. For example, a country input that resets a city input on change.
Would you need to update an input when another one changes, use the [`useForm`](https://final-form.org/docs/react-final-form/api/useForm) hook from `react-final-form`. For example, a country input that resets a city input on change.

```jsx
import * as React from 'react';
Expand Down Expand Up @@ -1814,7 +1814,7 @@ import { FormDataConsumer } from 'react-admin';
);
```

**Tip**: When using a `FormDataConsumer` you can define `subscription` prop to pass to the `react-final-form`
**Tip**: When using a `FormDataConsumer` you can define [`subscription`](https://final-form.org/docs/react-final-form/types/FormProps#subscription) prop to pass to the `react-final-form`

{% raw %}
```jsx
Expand Down

0 comments on commit dcb2a2e

Please sign in to comment.