Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
61e9ec46
Commit
61e9ec46
authored
Sep 24, 2011
by
Dries
Browse files
- Patch
#706894
by amateescu, sun: poll form uses #description for a button.
parent
e65cdab9
Changes
3
Hide whitespace changes
Inline
Side-by-side
modules/node/node.test
View file @
61e9ec46
...
...
@@ -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
choice
s
'
));
$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'
);
...
...
modules/poll/poll.module
View file @
61e9ec46
...
...
@@ -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 choice
s
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
...
...
modules/poll/poll.test
View file @
61e9ec46
...
...
@@ -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
choice
s
'
));
$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
choice
s
'
)));
$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
)));
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment