From 936349a844b97a73c03144dae17f5eef8e3864a5 Mon Sep 17 00:00:00 2001 From: Sebastien Romain Date: Wed, 25 Oct 2023 11:24:32 +0200 Subject: [PATCH] Handle default value --- packages/forms/src/rhf/fields/Input/RHFInput.component.js | 5 +++-- packages/forms/src/rhf/fields/Select/RHFSelect.component.js | 5 +++-- .../forms/src/rhf/fields/TextArea/RHFTextArea.component.js | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/forms/src/rhf/fields/Input/RHFInput.component.js b/packages/forms/src/rhf/fields/Input/RHFInput.component.js index 9d16d657a0..7702743c5e 100644 --- a/packages/forms/src/rhf/fields/Input/RHFInput.component.js +++ b/packages/forms/src/rhf/fields/Input/RHFInput.component.js @@ -3,13 +3,13 @@ import { useController, useFormContext } from 'react-hook-form'; import Input from '../../../widgets/fields/Input'; -function RHFInput(props) { - const { rules = {}, name = '', ...rest } = props; +function RHFInput({ rules = {}, name = '', defaultValue, ...rest }) { const { control } = useFormContext(); const { field, fieldState } = useController({ control, name, rules, + defaultValue, }); return ; } @@ -18,6 +18,7 @@ if (process.env.NODE_ENV !== 'production') { RHFInput.propTypes = { rules: PropTypes.object, name: PropTypes.string, + defaultValue: PropTypes.string, }; } diff --git a/packages/forms/src/rhf/fields/Select/RHFSelect.component.js b/packages/forms/src/rhf/fields/Select/RHFSelect.component.js index 2aca0f54a7..ff403349cd 100644 --- a/packages/forms/src/rhf/fields/Select/RHFSelect.component.js +++ b/packages/forms/src/rhf/fields/Select/RHFSelect.component.js @@ -3,13 +3,13 @@ import { useController, useFormContext } from 'react-hook-form'; import Select from '../../../widgets/fields/Select'; -function RHFSelect(props) { - const { rules = {}, name = '', ...rest } = props; +function RHFSelect({ rules = {}, name = '', defaultValue, ...rest }) { const { control } = useFormContext(); const { field, fieldState } = useController({ control, name, rules, + defaultValue, }); return