From 511f9194a3816ba7a3cf3a5b105174801e5c7452 Mon Sep 17 00:00:00 2001 From: Niclas Norin <103985736+NiclasNorin@users.noreply.github.com> Date: Sun, 31 Mar 2024 20:34:08 +0200 Subject: [PATCH] fix: checkboxes crashing when empty (#88) --- source/php/Submission.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/php/Submission.php b/source/php/Submission.php index bf366303..340ac1f5 100644 --- a/source/php/Submission.php +++ b/source/php/Submission.php @@ -138,9 +138,14 @@ public function submit() foreach ($fields as $key => $field) { - if ($field['acf_fc_layout'] == 'checkbox' && is_array($field['values'])) { + if ( + $field['acf_fc_layout'] == 'checkbox' && + is_array($field['values']) && + !empty($_POST[sanitize_title($field['label'])]) + ) { $_POST['ange-vilka-handlingar-du-vill-bestalla'] = implode(",", $_POST[sanitize_title($field['label'])]); } + if ($field['acf_fc_layout'] == 'sender') { if (!empty($field['custom_sender_labels']['add_sender_labels'])) { $labels = array_merge($labels, array_filter($field['custom_sender_labels']));