mirror of
https://github.com/strapi/strapi.git
synced 2025-11-03 03:17:11 +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';
|
||||
}
|
||||
|
||||
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 (
|
||||
<FormattedMessage id={errorId}>
|
||||
{error => {
|
||||
@ -147,7 +170,7 @@ function Inputs({ autoFocus, keys, layout, name, onBlur }) {
|
||||
name={keys}
|
||||
onBlur={onBlur}
|
||||
onChange={onChange}
|
||||
options={get(attribute, 'enum', [])}
|
||||
options={enumOptions}
|
||||
step={step}
|
||||
type={getInputType(type)}
|
||||
validations={validations}
|
||||
|
||||
@ -196,7 +196,8 @@ const EditViewDataManagerProvider = ({
|
||||
inputValue = null;
|
||||
}
|
||||
|
||||
if (type === 'biginteger' && value === '') {
|
||||
// Allow to reset enum
|
||||
if (type === 'select-one' && value === '') {
|
||||
inputValue = null;
|
||||
}
|
||||
|
||||
|
||||
@ -42,7 +42,11 @@ yup.addMethod(yup.string, 'unique', function(
|
||||
|
||||
yup.addMethod(yup.array, 'hasNotEmptyValues', function(message) {
|
||||
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