Skip to content

Commit

Permalink
migrate component :)
Browse files Browse the repository at this point in the history
  • Loading branch information
romainseb committed Oct 23, 2023
1 parent d18e3ac commit a03bb9a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 deletions packages/forms/src/rhf/fields/Input/RHFInput.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ import get from 'lodash/get';
import Input from '../../../widgets/fields/Input';

function RHFInput(props) {
const { rules = {}, ...rest } = props;
const { rules = {}, name = '', ...rest } = props;
const { errors, register } = useFormContext();
const error = get(errors, rest.name)?.message;
return <Input {...rest} ref={register(rules)} error={error} />;
return <Input {...rest} {...register(name, rules)} error={error} />;
}

if (process.env.NODE_ENV !== 'production') {
RHFInput.propTypes = {
rules: PropTypes.object,
name: PropTypes.string,
};
}

Expand Down
5 changes: 3 additions & 2 deletions packages/forms/src/rhf/fields/Select/RHFSelect.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ import get from 'lodash/get';
import Select from '../../../widgets/fields/Select';

function RHFSelect(props) {
const { rules = {}, ...rest } = props;
const { rules = {}, name = '', ...rest } = props;
const { errors, register } = useFormContext();
const error = get(errors, rest.name)?.message;
return <Select {...rest} ref={register(rules)} error={error} />;
return <Select {...rest} {...register(name, rules)} error={error} />;
}

if (process.env.NODE_ENV !== 'production') {
RHFSelect.propTypes = {
rules: PropTypes.object,
name: PropTypes.string,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ import get from 'lodash/get';
import TextArea from '../../../widgets/fields/TextArea';

function RHFTextArea(props) {
const { rules = {}, ...rest } = props;
const { rules = {}, name = '', ...rest } = props;
const { errors, register } = useFormContext();
const error = get(errors, rest.name)?.message;
return <TextArea {...rest} ref={register(rules)} error={error} />;
return <TextArea {...rest} {...register(name, rules)} error={error} />;
}

if (process.env.NODE_ENV !== 'production') {
RHFTextArea.propTypes = {
rules: PropTypes.object,
name: PropTypes.string,
};
}

Expand Down

0 comments on commit a03bb9a

Please sign in to comment.