Commit 62b610d8 authored by Dries's avatar Dries

- Patch #48918 by chx: remove POST from poll.

parent adb74caa
......@@ -102,7 +102,7 @@ function drupal_get_form($form_id, &$form, $callback = NULL) {
$function($form_id, $form);
}
$form = _form_builder($form_id, $form);
$form = form_builder($form_id, $form);
$goto = $_GET['q'];
if (!empty($_POST['edit']) && (($_POST['edit']['form_id'] == $form_id) || ($_POST['edit']['form_id'] == $callback))) {
drupal_validate_form($form_id, $form, $callback);
......@@ -270,11 +270,17 @@ function form_error(&$element, $message = '') {
}
/**
* Adds some required properties to each form element, which are used internally in the form api.
* This function also automatically assigns the value property from the $edit array, provided the
* element doesn't already have an assigned value.
* Adds some required properties to each form element, which are used
* internally in the form api. This function also automatically assigns
* the value property from the $edit array, provided the element doesn't
* already have an assigned value.
*
* @param $form_id
* A unique string identifying the form. Allows each form to be themed.
* @param $form
* An associative array containing the structure of the form.
*/
function _form_builder($form_id, $form) {
function form_builder($form_id, $form) {
global $form_values;
global $form_submitted;
/* Use element defaults */
......@@ -361,7 +367,7 @@ function _form_builder($form_id, $form) {
if (!isset($form[$key]['#weight'])) {
$form[$key]['#weight'] = $count/1000;
}
$form[$key] = _form_builder($form_id, $form[$key]);
$form[$key] = form_builder($form_id, $form[$key]);
$count++;
}
......
......@@ -137,22 +137,23 @@ function poll_form(&$node) {
$node->choices = max(2, count($node->choice) ? count($node->choice) : 5);
}
// User ticked 'need more choices'.
if ($_POST['edit']['morechoices']) {
$node->choices *= 2;
$form['choice']['choices'] = array('#type' => 'hidden', '#default_value' => $node->choices);
$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'];
}
// Poll choices
$opts = drupal_map_assoc(range(2, $node->choices * 2 + 5));
$form['choice'] = array('#type' => 'fieldset', '#title' => t('Choices'), '#prefix' => '<div class="poll-form">', '#suffix' => '</div>', '#tree' => TRUE);
$form['choice'] += array('#type' => 'fieldset', '#title' => t('Choices'), '#prefix' => '<div class="poll-form">', '#suffix' => '</div>', '#tree' => TRUE);
for ($a = 0; $a < $node->choices; $a++) {
$form['choice'][$a]['chtext'] = array('#type' => 'textfield', '#title' => t('Choice %n', array('%n' => ($a + 1))), '#default_value' => $node->choice[$a]['chtext']);
if ($admin) {
$form['choice'][$a]['chvotes'] = array('#type' => 'textfield', '#title' => t('Votes for choice %n', array('%n' => ($a + 1))), '#default_value' => (int)$node->choice[$a]['chvotes'], '#size' => 5, '#maxlength' => 7);
}
}
$form['choices'] = array('#type' => 'hidden', '#value' => $node->choices);
$form['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."));
// Poll attributes
$_duration = array(0 => t('Unlimited')) + drupal_map_assoc(array(86400, 172800, 345600, 604800, 1209600, 2419200, 4838400, 9676800, 31536000), "format_interval");
......
......@@ -137,22 +137,23 @@ function poll_form(&$node) {
$node->choices = max(2, count($node->choice) ? count($node->choice) : 5);
}
// User ticked 'need more choices'.
if ($_POST['edit']['morechoices']) {
$node->choices *= 2;
$form['choice']['choices'] = array('#type' => 'hidden', '#default_value' => $node->choices);
$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'];
}
// Poll choices
$opts = drupal_map_assoc(range(2, $node->choices * 2 + 5));
$form['choice'] = array('#type' => 'fieldset', '#title' => t('Choices'), '#prefix' => '<div class="poll-form">', '#suffix' => '</div>', '#tree' => TRUE);
$form['choice'] += array('#type' => 'fieldset', '#title' => t('Choices'), '#prefix' => '<div class="poll-form">', '#suffix' => '</div>', '#tree' => TRUE);
for ($a = 0; $a < $node->choices; $a++) {
$form['choice'][$a]['chtext'] = array('#type' => 'textfield', '#title' => t('Choice %n', array('%n' => ($a + 1))), '#default_value' => $node->choice[$a]['chtext']);
if ($admin) {
$form['choice'][$a]['chvotes'] = array('#type' => 'textfield', '#title' => t('Votes for choice %n', array('%n' => ($a + 1))), '#default_value' => (int)$node->choice[$a]['chvotes'], '#size' => 5, '#maxlength' => 7);
}
}
$form['choices'] = array('#type' => 'hidden', '#value' => $node->choices);
$form['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."));
// Poll attributes
$_duration = array(0 => t('Unlimited')) + drupal_map_assoc(array(86400, 172800, 345600, 604800, 1209600, 2419200, 4838400, 9676800, 31536000), "format_interval");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment