Skip to content

Commit

Permalink
moved isRequired to InputProps as optional boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
FACOLOMBANI committed Feb 5, 2021
1 parent d8c417f commit 63789e5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/ra-core/src/form/useInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface InputProps<T = any>
resource?: string;
source: string;
validate?: Validator | Validator[];
isRequired?: boolean;
}

export interface UseInputValue extends FieldRenderProps<any, HTMLElement> {
Expand All @@ -41,6 +42,7 @@ const useInput = ({
onBlur: customOnBlur,
onChange: customOnChange,
onFocus: customOnFocus,
isRequired: isRequiredOption,
...options
}: InputProps): UseInputValue => {
const finalName = name || source;
Expand Down Expand Up @@ -97,7 +99,7 @@ const useInput = ({
id: id || source,
input: options.input,
meta: options.meta,
isRequired: options.isRequired || isRequired(validate),
isRequired: isRequiredOption || isRequired(validate),
};
}

Expand All @@ -110,7 +112,7 @@ const useInput = ({
onFocus: handleFocus,
},
meta,
isRequired: isRequired(validate),
isRequired: isRequiredOption || isRequired(validate),
};
};

Expand Down

0 comments on commit 63789e5

Please sign in to comment.