Allow saving form also when list selection with lists is present

[MAILPOET-2828]
This commit is contained in:
Rostislav Wolny
2020-04-02 17:59:31 +02:00
committed by Veljko V
parent bef9267593
commit 201c1c7656
2 changed files with 29 additions and 2 deletions

View File

@@ -7,8 +7,12 @@ export default (formData, formBlocks) => {
if (!Array.isArray(formBlocks)) {
throw new Error('formBlocks are expected to be an array.');
}
const customSegmentsBlock = findBlock(formBlocks, 'mailpoet-form/segment-select');
const errors = [];
if (!formData.settings.segments || formData.settings.segments.length === 0) {
if (
(!customSegmentsBlock || customSegmentsBlock.attributes.values.length === 0)
&& (!formData.settings.segments || formData.settings.segments.length === 0)
) {
errors.push('missing-lists');
}
const emailInput = findBlock(formBlocks, 'mailpoet-form/email-input');