diff --git a/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/07_ReactJS_Redux_and_GraphQL.md b/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/07_ReactJS_Redux_and_GraphQL.md index 1f27969a0..94734639e 100644 --- a/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/07_ReactJS_Redux_and_GraphQL.md +++ b/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/07_ReactJS_Redux_and_GraphQL.md @@ -510,14 +510,11 @@ Injector.transform( (updater) => { updater.form.alterSchema( 'AssetAdmin.*', - (updateSchema) => (form, values) => ( - updateSchema( - form.updateField('Title', { - myCustomProp: true - }) - .getState() - ) - ) + (values, form) => + form.updateField('Title', { + myCustomProp: true + }) + .getState() ) } ); @@ -552,14 +549,10 @@ Injector.transform( (updater) => { updater.form.addValidation( 'AssetAdmin.*', - (validate) => (values, errors) => ( - validate( - values, - { - PostalCode: values.PostalCode.length !== 5 ? 'Invalid postal code' : null - } - ) - ) + (values, errors) => ({ + ...errors, + PostalCode: values.PostalCode.length !== 5 ? 'Invalid postal code' : null, + }) ) } ); diff --git a/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Customise_React_Forms.md b/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Customise_React_Forms.md index 5157bd2ea..aa339f702 100644 --- a/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Customise_React_Forms.md +++ b/docs/en/02_Developer_Guides/15_Customising_the_Admin_Interface/How_Tos/Customise_React_Forms.md @@ -49,15 +49,12 @@ Injector.transform( (updater) => { updater.form.alterSchema( 'AssetAdmin.*', - (updateSchema) => (values, form) => { - return updateSchema( - form - .updateField('State', { - shouldHide: values.Country !== 'US' - }) - .getState() - ) - } + (values, form) => + form + .updateField('State', { + shouldHide: values.Country !== 'US' + }) + .getState() ) } ); @@ -74,13 +71,10 @@ Injector.transform( (updater) => { updater.form.alterSchema( 'AssetAdmin.*', - (updateSchema) => (values, form) => { - return updateSchema( - form - .setFieldClass('Price', 'danger', (values.TicketsRemaining < 10)) - .getState() - ) - } + (values, form) => + form + .setFieldClass('Price', 'danger', (values.TicketsRemaining < 10)) + .getState() ); } ); @@ -122,13 +116,10 @@ Injector.transform( (updater) => { updater.form.alterSchema( 'AssetAdmin.*', - (updateSchema) => (values, form) => { - return updateSchema( - form - .setFieldComponent('PhoneNumber', 'PrettyPhoneNumberField') - .getState() - ) - } + (values, form) => + form + .setFieldComponent('PhoneNumber', 'PrettyPhoneNumberField') + .getState() ); } ); @@ -144,18 +135,15 @@ Injector.transform( (updater) => { updater.form.addValidation( 'AssetAdmin.*', - (validate) => (values, errors) => { + (values, errors) => { const requiredLength = values.Country === 'US' ? 5 : 4; if (!values.Country || !values.PostalCode) { return; } - return validate( - values, - { - ...errors, - PostalCode: values.PostalCode.length !== requiredLength ? 'Invalid postal code' : null - } - ); + return { + ...errors, + PostalCode: values.PostalCode.length !== requiredLength ? 'Invalid postal code' : null, + }; } ) } @@ -197,7 +185,6 @@ export default (FormAction) => { } render() { - const extraButtons = []; const { confirmText, cancelText } = this.props; const buttonProps = { ...this.props, @@ -238,17 +225,14 @@ Injector.transform( (updater) => { updater.form.alterSchema( 'AssetAdmin.*', - (updateSchema) => (values, form) => { - return updateSchema( + (values, form) => form .updateField('action_delete', { confirmText: 'Are you sure you want to delete?', cancelText: 'No!! Cancel!!!!' }) .getState() - ) - } - ); + ) } ); ```