From 2373e9e20326f6cdd6db84e20eaf158e2eb10b14 Mon Sep 17 00:00:00 2001 From: NiclasNorin <103985736+NiclasNorin@users.noreply.github.com> Date: Wed, 4 Oct 2023 11:45:06 +0200 Subject: [PATCH] Revert "Feature/require image" --- source/js/front/form-submit.js | 8 ++++++-- source/php/Module/EventForm/Fields.php | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/source/js/front/form-submit.js b/source/js/front/form-submit.js index 5ee8ea21..9c3db1cc 100644 --- a/source/js/front/form-submit.js +++ b/source/js/front/form-submit.js @@ -22,7 +22,11 @@ const eventFormSubmit = { imageData.append('file', imageInput.files[0]); const formRequests = []; - formRequests.push(eventFormSubmit.submitImageData(imageData)); + if (imageInput.files[0]) { + formRequests.push(eventFormSubmit.submitImageData(imageData)); + } else { + formRequests.push(null); + } const formUserGroups = formData.user_groups.join(','); @@ -83,7 +87,7 @@ const eventFormSubmit = { formData['location'] = locationResponse.data.id; } - const errorResponses = [imageResponse, organizerResponse, locationResponse].filter(x => !Array.isArray(x) && !x.success).map(x => x.data); + const errorResponses = [organizerResponse, locationResponse].filter(x => !Array.isArray(x) && !x.success).map(x => x.data); if (!errorResponses.length > 0) { eventFormSubmit.submitFormData(formData, 'submit_event').then(response => { if (response.success) { diff --git a/source/php/Module/EventForm/Fields.php b/source/php/Module/EventForm/Fields.php index bae5601f..2233815f 100644 --- a/source/php/Module/EventForm/Fields.php +++ b/source/php/Module/EventForm/Fields.php @@ -52,7 +52,7 @@ public static function get(?int $id = 0) ) . '
' . __('You must also have the right to use and distribute the image.', 'event-integration'), 'type' => 'image', - 'required' => true, + 'required' => !empty($data['image_input']['required']), 'aspectRatio' => '16:9' ], [