From e8a1f37c981fbe0d7ac09e0ec4de9ca8ad5abc42 Mon Sep 17 00:00:00 2001 From: Olivier PEREZ Date: Sun, 31 May 2015 15:57:44 +0200 Subject: [PATCH] Date poll creation: Always propose 3 choices and 3 slots when choosing dates --- create_date_poll.php | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/create_date_poll.php b/create_date_poll.php index f170b5b..d33e48f 100644 --- a/create_date_poll.php +++ b/create_date_poll.php @@ -221,17 +221,15 @@ if (!isset($_SESSION['form']->title) || !isset($_SESSION['form']->admin_name) || } else { // Prefill form->choices - if (count($_SESSION['form']->getChoices()) == 0) { - $c = new Choice(''); - $c->addSlot(''); - $c->addSlot(''); - $c->addSlot(''); - $_SESSION['form']->addChoice($c); - $c = new Choice(''); - $c->addSlot(''); - $c->addSlot(''); - $c->addSlot(''); - $_SESSION['form']->addChoice($c); + foreach ($_SESSION['form']->getChoices() as $c) { + $count = 3 - count($c->getSlots()); + for($i=0; $i< $count; $i++) { + $c->addSlot(''); + } + } + + $count = 3 - count($_SESSION['form']->getChoices()); + for($i=0; $i< $count; $i++) { $c = new Choice(''); $c->addSlot(''); $c->addSlot('');