Commit 61e9ec46 authored by Dries's avatar Dries
Browse files

- Patch #706894 by amateescu, sun: poll form uses #description for a button.

parent e65cdab9
......@@ -1922,7 +1922,7 @@ class MultiStepNodeFormBasicOptionsTest extends DrupalWebTestCase {
'choice[new:0][chtext]' => 'a',
'choice[new:1][chtext]' => 'a',
);
$this->drupalPost('node/add/poll', $edit, t('More choices'));
$this->drupalPost('node/add/poll', $edit, t('Add another choice'));
$this->assertNoFieldChecked('edit-status', 'status stayed unchecked');
$this->assertNoFieldChecked('edit-promote', 'promote stayed unchecked');
$this->assertFieldChecked('edit-sticky', 'sticky stayed checked');
......
......@@ -298,8 +298,7 @@ function poll_form($node, &$form_state) {
// Ajax-enabled buttons with the id 'more'.
$form['choice_wrapper']['poll_more'] = array(
'#type' => 'submit',
'#value' => t('More choices'),
'#description' => t("If the amount of boxes above isn't enough, click here to add more choices."),
'#value' => t('Add another choice'),
'#weight' => 1,
'#limit_validation_errors' => array(array('choice')),
'#submit' => array('poll_more_choices_submit'),
......@@ -361,10 +360,9 @@ function poll_form($node, &$form_state) {
* return just the changed part of the form.
*/
function poll_more_choices_submit($form, &$form_state) {
// If this is a Ajax POST, add 1, otherwise add 5 more choices to the form.
// Add one more choice to the form.
if ($form_state['values']['poll_more']) {
$n = $_GET['q'] == 'system/ajax' ? 1 : 5;
$form_state['choice_count'] = count($form_state['values']['choice']) + $n;
$form_state['choice_count'] = count($form_state['values']['choice']) + 1;
}
// Renumber the choices. This invalidates the corresponding key/value
// associations in $form_state['input'], so clear that out. This requires
......
......@@ -36,7 +36,7 @@ class PollTestCase extends DrupalWebTestCase {
// Re-submit the form until all choices are filled in.
if (count($choices) > 2) {
while ($index < count($choices)) {
$this->drupalPost(NULL, $edit, t('More choices'));
$this->drupalPost(NULL, $edit, t('Add another choice'));
$this->assertPollChoiceOrder($choices, $index);
list($edit, $index) = $this->_pollGenerateEdit($title, $choices, $index);
}
......@@ -76,7 +76,7 @@ class PollTestCase extends DrupalWebTestCase {
* in subsequent invocations of this function.
*/
function _pollGenerateEdit($title, array $choices, $index = 0) {
$max_new_choices = ($index == 0 ? 2 : 5);
$max_new_choices = ($index == 0 ? 2 : 1);
$already_submitted_choices = array_slice($choices, 0, $index);
$new_choices = array_values(array_slice($choices, $index, $max_new_choices));
......@@ -446,7 +446,7 @@ class PollJSAddChoice extends DrupalWebTestCase {
// Press 'add choice' button through Ajax, and place the expected HTML result
// as the tested content.
$commands = $this->drupalPostAJAX(NULL, $edit, array('op' => t('More choices')));
$commands = $this->drupalPostAJAX(NULL, $edit, array('op' => t('Add another choice')));
$this->content = $commands[1]['data'];
$this->assertFieldByName('choice[chid:0][chtext]', $edit['choice[new:0][chtext]'], t('Field !i found', array('!i' => 0)));
......
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