mirror of
https://github.com/strapi/strapi.git
synced 2025-08-18 21:57:46 +00:00
Merge pull request #4771 from strapi/ctm/fix-components
Fix edit component with min value when not required
This commit is contained in:
commit
d6a00ccffd
@ -52,6 +52,7 @@ const RepeatableComponent = ({
|
|||||||
const errorsArray = componentErrorKeys.map(key =>
|
const errorsArray = componentErrorKeys.map(key =>
|
||||||
get(formErrors, [key, 'id'], '')
|
get(formErrors, [key, 'id'], '')
|
||||||
);
|
);
|
||||||
|
|
||||||
const hasMinError =
|
const hasMinError =
|
||||||
get(errorsArray, [0], '').includes('min') &&
|
get(errorsArray, [0], '').includes('min') &&
|
||||||
!collapses.some(obj => obj.isOpen === true);
|
!collapses.some(obj => obj.isOpen === true);
|
||||||
|
@ -266,7 +266,7 @@ const EditViewDataManagerProvider = ({
|
|||||||
});
|
});
|
||||||
redirectToPreviousPage();
|
redirectToPreviousPage();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log({ err });
|
console.error({ err });
|
||||||
const error = get(
|
const error = get(
|
||||||
err,
|
err,
|
||||||
['response', 'payload', 'message', '0', 'messages', '0', 'id'],
|
['response', 'payload', 'message', '0', 'messages', '0', 'id'],
|
||||||
@ -281,6 +281,7 @@ const EditViewDataManagerProvider = ({
|
|||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const errors = getYupInnerErrors(err);
|
const errors = getYupInnerErrors(err);
|
||||||
|
console.error({ err, errors });
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: 'SUBMIT_ERRORS',
|
type: 'SUBMIT_ERRORS',
|
||||||
|
@ -109,7 +109,26 @@ const createYupSchema = (model, { components }) => {
|
|||||||
.nullable();
|
.nullable();
|
||||||
|
|
||||||
if (min) {
|
if (min) {
|
||||||
componentSchema = componentSchema.min(min, errorsTrads.min);
|
componentSchema = yup.lazy(array => {
|
||||||
|
if (attribute.required) {
|
||||||
|
return yup
|
||||||
|
.array()
|
||||||
|
.of(componentFieldSchema)
|
||||||
|
.defined()
|
||||||
|
.min(min, errorsTrads.min);
|
||||||
|
}
|
||||||
|
|
||||||
|
let schema = yup
|
||||||
|
.array()
|
||||||
|
.of(componentFieldSchema)
|
||||||
|
.nullable();
|
||||||
|
|
||||||
|
if (array && !isEmpty(array)) {
|
||||||
|
schema = schema.min(min, errorsTrads.min);
|
||||||
|
}
|
||||||
|
|
||||||
|
return schema;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (max) {
|
if (max) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user