diff --git a/create_date_poll.php b/create_date_poll.php index 0de33ee..b76ed46 100644 --- a/create_date_poll.php +++ b/create_date_poll.php @@ -120,6 +120,17 @@ switch ($step) { // Clear previous choices $_SESSION['form']->clearChoices(); + // Reorder moments to deal with suppressed dates + $moments = array(); + $i = 0; + while(count($moments) < count($_POST['days'])) { + if (!empty($_POST['horaires' . $i])) { + $moments[] = $_POST['horaires' . $i]; + } + $i++; + } + + for ($i = 0; $i < count($_POST['days']); $i++) { $day = $_POST['days'][$i]; @@ -130,7 +141,7 @@ switch ($step) { $choice = new Choice($time); $_SESSION['form']->addChoice($choice); - $schedules = $inputService->filterArray($_POST['horaires' . $i], FILTER_DEFAULT); + $schedules = $inputService->filterArray($moments[$i], FILTER_DEFAULT); for ($j = 0; $j < count($schedules); $j++) { if (!empty($schedules[$j])) { $choice->addSlot(strip_tags($schedules[$j]));