fix(ui): show required indicator for select fields (#9348)
### What? Select field was not showing required indicator despite being marked required in config. ### Why? To give end-user feedback when editting required select fields. ### How? Replacing hardcoded required prop with required prop passed in from config. [See here.](https://github.com/payloadcms/payload/blob/main/packages/ui/src/fields/Select/Input.tsx#L100)
This commit is contained in:
@@ -33,6 +33,7 @@ export type SelectInputProps = {
|
||||
readonly options?: OptionObject[]
|
||||
readonly path: string
|
||||
readonly readOnly?: boolean
|
||||
readonly required?: boolean
|
||||
readonly showError?: boolean
|
||||
readonly style?: React.CSSProperties
|
||||
readonly value?: string | string[]
|
||||
@@ -56,6 +57,7 @@ export const SelectInput: React.FC<SelectInputProps> = (props) => {
|
||||
options,
|
||||
path,
|
||||
readOnly,
|
||||
required,
|
||||
showError,
|
||||
style,
|
||||
value,
|
||||
@@ -97,7 +99,9 @@ export const SelectInput: React.FC<SelectInputProps> = (props) => {
|
||||
>
|
||||
<RenderCustomComponent
|
||||
CustomComponent={Label}
|
||||
Fallback={<FieldLabel label={label} localized={localized} path={path} required={false} />}
|
||||
Fallback={
|
||||
<FieldLabel label={label} localized={localized} path={path} required={required} />
|
||||
}
|
||||
/>
|
||||
<div className={`${fieldBaseClass}__wrap`}>
|
||||
<RenderCustomComponent
|
||||
|
||||
@@ -117,6 +117,7 @@ const SelectFieldComponent: SelectFieldClientComponent = (props) => {
|
||||
options={options}
|
||||
path={path}
|
||||
readOnly={readOnly}
|
||||
required={required}
|
||||
showError={showError}
|
||||
style={styles}
|
||||
value={value as string | string[]}
|
||||
|
||||
Reference in New Issue
Block a user