diff --git a/modules/poll.module b/modules/poll.module index 8c6f6be552ef397d5871296fcdd874d2d9edcf2d..d2e62de64a7bf9131880511a09003f51dd66bfcd 100644 --- a/modules/poll.module +++ b/modules/poll.module @@ -133,19 +133,17 @@ function poll_form(&$node) { $form['title'] = array('#type' => 'textfield', '#title' => t('Question'), '#required' => TRUE, '#default_value' => $node->title, '#weight' => -1); - if (!isset($node->choices)) { - $node->choices = max(2, count($node->choice) ? count($node->choice) : 5); - } - - $form['choice']['choices'] = array('#type' => 'hidden', '#default_value' => $node->choices); + $form['choice']['choices'] = array('#type' => 'hidden', '#default_value' => max(2, count($node->choice) ? count($node->choice) : 5)); $form['choice']['morechoices'] = array('#type' => 'checkbox', '#title' => t('Need more choices'), '#default_value' => 0, '#description' => t("If the amount of boxes above isn't enough, check this box and click the Preview button below to add some more."), '#weight' => 1); $form['choice'] = form_builder('poll_node_form', $form['choice']); if ($form['choice']['morechoices']['#value']) { $form['choice']['morechoices']['#value'] = 0; $form['choice']['choices']['#value'] *= 2; - $node->choices = $form['choice']['choices']['#value']; } + // if the value was changed in a previous iteration, retain it. + $node->choices = $form['choice']['choices']['#value']; + // Poll choices $form['choice'] += array('#type' => 'fieldset', '#title' => t('Choices'), '#prefix' => '<div class="poll-form">', '#suffix' => '</div>', '#tree' => TRUE); for ($a = 0; $a < $node->choices; $a++) { diff --git a/modules/poll/poll.module b/modules/poll/poll.module index 8c6f6be552ef397d5871296fcdd874d2d9edcf2d..d2e62de64a7bf9131880511a09003f51dd66bfcd 100644 --- a/modules/poll/poll.module +++ b/modules/poll/poll.module @@ -133,19 +133,17 @@ function poll_form(&$node) { $form['title'] = array('#type' => 'textfield', '#title' => t('Question'), '#required' => TRUE, '#default_value' => $node->title, '#weight' => -1); - if (!isset($node->choices)) { - $node->choices = max(2, count($node->choice) ? count($node->choice) : 5); - } - - $form['choice']['choices'] = array('#type' => 'hidden', '#default_value' => $node->choices); + $form['choice']['choices'] = array('#type' => 'hidden', '#default_value' => max(2, count($node->choice) ? count($node->choice) : 5)); $form['choice']['morechoices'] = array('#type' => 'checkbox', '#title' => t('Need more choices'), '#default_value' => 0, '#description' => t("If the amount of boxes above isn't enough, check this box and click the Preview button below to add some more."), '#weight' => 1); $form['choice'] = form_builder('poll_node_form', $form['choice']); if ($form['choice']['morechoices']['#value']) { $form['choice']['morechoices']['#value'] = 0; $form['choice']['choices']['#value'] *= 2; - $node->choices = $form['choice']['choices']['#value']; } + // if the value was changed in a previous iteration, retain it. + $node->choices = $form['choice']['choices']['#value']; + // Poll choices $form['choice'] += array('#type' => 'fieldset', '#title' => t('Choices'), '#prefix' => '<div class="poll-form">', '#suffix' => '</div>', '#tree' => TRUE); for ($a = 0; $a < $node->choices; $a++) {