mirror of
https://github.com/strapi/strapi.git
synced 2025-11-10 23:29:33 +00:00
Fixes #2471
This commit is contained in:
parent
d6a00ccffd
commit
c2ee96c355
@ -121,6 +121,29 @@ function Inputs({ autoFocus, keys, layout, name, onBlur }) {
|
|||||||
step = '1';
|
step = '1';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const options = get(attribute, 'enum', []).map(v => {
|
||||||
|
return (
|
||||||
|
<option key={v} value={v}>
|
||||||
|
{v}
|
||||||
|
</option>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const isRequired = get(validations, ['required'], false);
|
||||||
|
const enumOptions = [
|
||||||
|
<FormattedMessage
|
||||||
|
id="components.InputSelect.option.placeholder"
|
||||||
|
key="__enum_option_null"
|
||||||
|
>
|
||||||
|
{msg => (
|
||||||
|
<option disabled={isRequired} hidden={isRequired} value="">
|
||||||
|
{msg}
|
||||||
|
</option>
|
||||||
|
)}
|
||||||
|
</FormattedMessage>,
|
||||||
|
...options,
|
||||||
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FormattedMessage id={errorId}>
|
<FormattedMessage id={errorId}>
|
||||||
{error => {
|
{error => {
|
||||||
@ -147,7 +170,7 @@ function Inputs({ autoFocus, keys, layout, name, onBlur }) {
|
|||||||
name={keys}
|
name={keys}
|
||||||
onBlur={onBlur}
|
onBlur={onBlur}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
options={get(attribute, 'enum', [])}
|
options={enumOptions}
|
||||||
step={step}
|
step={step}
|
||||||
type={getInputType(type)}
|
type={getInputType(type)}
|
||||||
validations={validations}
|
validations={validations}
|
||||||
|
|||||||
@ -196,7 +196,8 @@ const EditViewDataManagerProvider = ({
|
|||||||
inputValue = null;
|
inputValue = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type === 'biginteger' && value === '') {
|
// Allow to reset enum
|
||||||
|
if (type === 'select-one' && value === '') {
|
||||||
inputValue = null;
|
inputValue = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -42,7 +42,11 @@ yup.addMethod(yup.string, 'unique', function(
|
|||||||
|
|
||||||
yup.addMethod(yup.array, 'hasNotEmptyValues', function(message) {
|
yup.addMethod(yup.array, 'hasNotEmptyValues', function(message) {
|
||||||
return this.test('hasNotEmptyValues', message, function(array) {
|
return this.test('hasNotEmptyValues', message, function(array) {
|
||||||
return !array.some(value => isEmpty(value));
|
return (
|
||||||
|
!array.some(value => {
|
||||||
|
return isEmpty(value);
|
||||||
|
}) && array.every(value => ENUM_REGEX.test(value))
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user