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
b46e90ad
Commit
b46e90ad
authored
Mar 14, 2009
by
Dries
Browse files
- Patch
#322344
by merlinofchaos, Frando, catch, sun: form improvements from Views.
parent
c85fa2b0
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
includes/form.inc
View file @
b46e90ad
This diff is collapsed.
Click to expand it.
modules/book/book.admin.inc
View file @
b46e90ad
...
...
@@ -114,7 +114,7 @@ function book_admin_edit_validate($form, &$form_state) {
function
book_admin_edit_submit
(
$form
,
&
$form_state
)
{
// Save elements in the same order as defined in post rather than the form.
// This ensures parents are updated before their children, preventing orphans.
$order
=
array_flip
(
array_keys
(
$form
[
'#pos
t'
][
'table'
]));
$order
=
array_flip
(
array_keys
(
$form
_state
[
'inpu
t'
][
'table'
]));
$form
[
'table'
]
=
array_merge
(
$order
,
$form
[
'table'
]);
foreach
(
element_children
(
$form
[
'table'
])
as
$key
)
{
...
...
modules/book/book.pages.inc
View file @
b46e90ad
...
...
@@ -246,7 +246,6 @@ function book_form_update() {
form_set_cache
(
$_POST
[
'form_build_id'
],
$form
,
$cached_form_state
);
// Build and render the new select element, then return it in JSON format.
$form_state
=
array
();
$form
[
'#post'
]
=
array
();
$form
=
form_builder
(
$form
[
'form_id'
][
'#value'
]
,
$form
,
$form_state
);
$output
=
drupal_render
(
$form
[
'book'
][
'plid'
]);
drupal_json
(
array
(
'status'
=>
TRUE
,
'data'
=>
$output
));
...
...
modules/comment/comment.admin.inc
View file @
b46e90ad
...
...
@@ -163,7 +163,7 @@ function comment_admin_overview_submit($form, &$form_state) {
* @see comment_multiple_delete_confirm_submit()
*/
function
comment_multiple_delete_confirm
(
&
$form_state
)
{
$edit
=
$form_state
[
'
pos
t'
];
$edit
=
$form_state
[
'
inpu
t'
];
$form
[
'comments'
]
=
array
(
'#prefix'
=>
'<ul>'
,
...
...
modules/menu/menu.admin.inc
View file @
b46e90ad
...
...
@@ -132,7 +132,7 @@ function menu_overview_form_submit($form, &$form_state) {
// parent. To prevent this, save items in the form in the same order they
// are sent by $_POST, ensuring parents are saved first, then their children.
// See http://drupal.org/node/181126#comment-632270
$order
=
array_flip
(
array_keys
(
$form
[
'#pos
t'
]));
// Get the $_POST order.
$order
=
array_flip
(
array_keys
(
$form
_state
[
'inpu
t'
]));
// Get the $_POST order.
$form
=
array_merge
(
$order
,
$form
);
// Update our original form with the new order.
$updated_items
=
array
();
...
...
modules/node/node.module
View file @
b46e90ad
...
...
@@ -293,7 +293,7 @@ function node_mark($nid, $timestamp) {
* See if the user used JS to submit a teaser.
*/
function
node_teaser_js
(
&
$form
,
&
$form_state
)
{
if
(
isset
(
$form
[
'#pos
t'
][
'teaser_js'
]))
{
if
(
isset
(
$form
_state
[
'inpu
t'
][
'teaser_js'
]))
{
// Glue the teaser to the body.
if
(
trim
(
$form_state
[
'values'
][
'teaser_js'
]))
{
// Space the teaser from the body
...
...
@@ -330,8 +330,8 @@ function node_teaser_js(&$form, &$form_state) {
function
node_teaser_include_verify
(
&
$form
,
&
$form_state
)
{
$message
=
''
;
// $form
['#pos
t'] is set only when the form is built for preview/submit.
if
(
isset
(
$form
[
'#pos
t'
][
'body'
])
&&
isset
(
$form_state
[
'values'
][
'teaser_include'
])
&&
!
$form_state
[
'values'
][
'teaser_include'
])
{
// $form
_state['inpu
t'] is set only when the form is built for preview/submit.
if
(
isset
(
$form
_state
[
'inpu
t'
][
'body'
])
&&
isset
(
$form_state
[
'values'
][
'teaser_include'
])
&&
!
$form_state
[
'values'
][
'teaser_include'
])
{
// "teaser_include" checkbox is present and unchecked.
if
(
strpos
(
$form_state
[
'values'
][
'body'
],
'<!--break-->'
)
===
0
)
{
// Teaser is empty string.
...
...
modules/openid/openid.module
View file @
b46e90ad
...
...
@@ -87,7 +87,7 @@ function openid_form_user_login_alter(&$form, &$form_state) {
function
_openid_user_login_form_alter
(
&
$form
,
&
$form_state
)
{
drupal_add_css
(
drupal_get_path
(
'module'
,
'openid'
)
.
'/openid.css'
);
drupal_add_js
(
drupal_get_path
(
'module'
,
'openid'
)
.
'/openid.js'
);
if
(
!
empty
(
$form_state
[
'
pos
t'
][
'openid_identifier'
]))
{
if
(
!
empty
(
$form_state
[
'
inpu
t'
][
'openid_identifier'
]))
{
$form
[
'name'
][
'#required'
]
=
FALSE
;
$form
[
'pass'
][
'#required'
]
=
FALSE
;
unset
(
$form
[
'#submit'
]);
...
...
modules/openid/openid.pages.inc
View file @
b46e90ad
...
...
@@ -88,10 +88,10 @@ function openid_user_delete_form($form_state, $account, $aid = 0) {
}
function
openid_user_delete_form_submit
(
&
$form_state
,
$form_values
)
{
db_query
(
"DELETE FROM
{
authmap
}
WHERE uid = %d AND aid = %d AND module = 'openid'"
,
$form_state
[
'#
p
ar
ameter
s'
][
2
]
->
uid
,
$form_state
[
'#
p
ar
ameter
s'
][
3
]);
db_query
(
"DELETE FROM
{
authmap
}
WHERE uid = %d AND aid = %d AND module = 'openid'"
,
$form_state
[
'#ar
g
s'
][
0
]
->
uid
,
$form_state
[
'#ar
g
s'
][
1
]);
if
(
db_affected_rows
())
{
drupal_set_message
(
t
(
'OpenID deleted.'
));
}
$form_state
[
'#redirect'
]
=
'user/'
.
$form_state
[
'#
p
ar
ameter
s'
][
2
]
->
uid
.
'/openid'
;
$form_state
[
'#redirect'
]
=
'user/'
.
$form_state
[
'#ar
g
s'
][
0
]
->
uid
.
'/openid'
;
}
modules/simpletest/tests/form.test
View file @
b46e90ad
...
...
@@ -60,8 +60,9 @@ class FormsTestCase extends DrupalWebTestCase {
$element
=
$data
[
'element'
][
'#title'
];
$form
[
$element
]
=
$data
[
'element'
];
$form_state
[
'values'
][
$element
]
=
$empty
;
$form
[
'#post'
]
=
$form_state
[
'values'
];
$form
[
'#post'
][
'form_id'
]
=
$form_id
;
$form_state
[
'input'
]
=
$form_state
[
'values'
];
$form_state
[
'input'
][
'form_id'
]
=
$form_id
;
$form_state
[
'method'
]
=
'post'
;
drupal_prepare_form
(
$form_id
,
$form
,
$form_state
);
drupal_process_form
(
$form_id
,
$form
,
$form_state
);
$errors
=
form_get_errors
();
...
...
@@ -288,13 +289,14 @@ class FormsElementsTableSelectFunctionalTest extends DrupalWebTestCase {
private
function
formSubmitHelper
(
$form_element
,
$edit
)
{
$form_id
=
$this
->
randomName
();
$form
=
$form_state
=
array
();
$form_state
=
form_state_defaults
();
$form
=
array
();
$form
=
array_merge
(
$form
,
$form_element
);
$form
[
'op'
]
=
array
(
'#type'
=>
'submit'
,
'#value'
=>
t
(
'Submit'
));
$form
[
'#pos
t'
]
=
$edit
;
$form
[
'#pos
t'
][
'form_id'
]
=
$form_id
;
$form
_state
[
'inpu
t'
]
=
$edit
;
$form
_state
[
'inpu
t'
][
'form_id'
]
=
$form_id
;
drupal_prepare_form
(
$form_id
,
$form
,
$form_state
);
...
...
modules/taxonomy/taxonomy.admin.inc
View file @
b46e90ad
...
...
@@ -344,13 +344,13 @@ function taxonomy_overview_terms(&$form_state, $vocabulary) {
// If this form was already submitted once, it's probably hit a validation
// error. Ensure the form is rebuilt in the same order as the user submitted.
if
(
!
empty
(
$form_state
[
'
pos
t'
]))
{
$order
=
array_flip
(
array_keys
(
$form_state
[
'
pos
t'
]));
// Get the $_POST order.
if
(
!
empty
(
$form_state
[
'
inpu
t'
]))
{
$order
=
array_flip
(
array_keys
(
$form_state
[
'
inpu
t'
]));
// Get the $_POST order.
$current_page
=
array_merge
(
$order
,
$current_page
);
// Update our form with the new order.
foreach
(
$current_page
as
$key
=>
$term
)
{
// Verify this is a term for the current page and set at the current depth.
if
(
is_array
(
$form_state
[
'
pos
t'
][
$key
])
&&
is_numeric
(
$form_state
[
'
pos
t'
][
$key
][
'tid'
]))
{
$current_page
[
$key
]
->
depth
=
$form_state
[
'
pos
t'
][
$key
][
'depth'
];
if
(
is_array
(
$form_state
[
'
inpu
t'
][
$key
])
&&
is_numeric
(
$form_state
[
'
inpu
t'
][
$key
][
'tid'
]))
{
$current_page
[
$key
]
->
depth
=
$form_state
[
'
inpu
t'
][
$key
][
'depth'
];
}
else
{
unset
(
$current_page
[
$key
]);
...
...
@@ -440,7 +440,7 @@ function taxonomy_overview_terms_submit($form, &$form_state) {
return
;
}
$order
=
array_flip
(
array_keys
(
$form
[
'#pos
t'
]));
// Get the $_POST order.
$order
=
array_flip
(
array_keys
(
$form
_state
[
'inpu
t'
]));
// Get the $_POST order.
$form_state
[
'values'
]
=
array_merge
(
$order
,
$form_state
[
'values'
]);
// Update our original form with the new order.
$vocabulary
=
$form
[
'#vocabulary'
];
...
...
modules/upload/upload.module
View file @
b46e90ad
...
...
@@ -689,13 +689,11 @@ function upload_js() {
// Render the form for output.
$form
+=
array
(
'#post'
=>
$_POST
,
'#programmed'
=>
FALSE
,
'#tree'
=>
FALSE
,
'#parents'
=>
array
(),
);
drupal_alter
(
'form'
,
$form
,
array
(),
'upload_js'
);
$form_state
=
array
(
'submitted'
=>
FALSE
);
$form_state
=
array
(
'submitted'
=>
FALSE
,
'programmed'
=>
FALSE
);
$form
=
form_builder
(
'upload_js'
,
$form
,
$form_state
);
$output
=
theme
(
'status_messages'
)
.
drupal_render
(
$form
);
...
...
modules/user/user.module
View file @
b46e90ad
...
...
@@ -2164,7 +2164,7 @@ function user_multiple_role_edit($accounts, $operation, $rid) {
}
function
user_multiple_cancel_confirm
(
&
$form_state
)
{
$edit
=
$form_state
[
'
pos
t'
];
$edit
=
$form_state
[
'
inpu
t'
];
$form
[
'accounts'
]
=
array
(
'#prefix'
=>
'<ul>'
,
'#suffix'
=>
'</ul>'
,
'#tree'
=>
TRUE
);
// array_filter() returns only elements with TRUE values.
...
...
Write
Preview
Markdown
is supported
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