Commit b46e90ad authored by Dries's avatar Dries

- Patch #322344 by merlinofchaos, Frando, catch, sun: form improvements from Views.

parent c85fa2b0
This diff is collapsed.
......@@ -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['#post']['table']));
$order = array_flip(array_keys($form_state['input']['table']));
$form['table'] = array_merge($order, $form['table']);
foreach (element_children($form['table']) as $key) {
......
......@@ -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));
......
......@@ -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['post'];
$edit = $form_state['input'];
$form['comments'] = array(
'#prefix' => '<ul>',
......
......@@ -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['#post'])); // Get the $_POST order.
$order = array_flip(array_keys($form_state['input'])); // Get the $_POST order.
$form = array_merge($order, $form); // Update our original form with the new order.
$updated_items = array();
......
......@@ -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['#post']['teaser_js'])) {
if (isset($form_state['input']['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['#post'] is set only when the form is built for preview/submit.
if (isset($form['#post']['body']) && isset($form_state['values']['teaser_include']) && !$form_state['values']['teaser_include']) {
// $form_state['input'] is set only when the form is built for preview/submit.
if (isset($form_state['input']['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.
......
......@@ -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['post']['openid_identifier'])) {
if (!empty($form_state['input']['openid_identifier'])) {
$form['name']['#required'] = FALSE;
$form['pass']['#required'] = FALSE;
unset($form['#submit']);
......
......@@ -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['#parameters'][2]->uid, $form_state['#parameters'][3]);
db_query("DELETE FROM {authmap} WHERE uid = %d AND aid = %d AND module = 'openid'", $form_state['#args'][0]->uid, $form_state['#args'][1]);
if (db_affected_rows()) {
drupal_set_message(t('OpenID deleted.'));
}
$form_state['#redirect'] = 'user/'. $form_state['#parameters'][2]->uid .'/openid';
$form_state['#redirect'] = 'user/'. $form_state['#args'][0]->uid .'/openid';
}
......@@ -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['#post'] = $edit;
$form['#post']['form_id'] = $form_id;
$form_state['input'] = $edit;
$form_state['input']['form_id'] = $form_id;
drupal_prepare_form($form_id, $form, $form_state);
......
......@@ -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['post'])) {
$order = array_flip(array_keys($form_state['post'])); // Get the $_POST order.
if (!empty($form_state['input'])) {
$order = array_flip(array_keys($form_state['input'])); // 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['post'][$key]) && is_numeric($form_state['post'][$key]['tid'])) {
$current_page[$key]->depth = $form_state['post'][$key]['depth'];
if (is_array($form_state['input'][$key]) && is_numeric($form_state['input'][$key]['tid'])) {
$current_page[$key]->depth = $form_state['input'][$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['#post'])); // Get the $_POST order.
$order = array_flip(array_keys($form_state['input'])); // Get the $_POST order.
$form_state['values'] = array_merge($order, $form_state['values']); // Update our original form with the new order.
$vocabulary = $form['#vocabulary'];
......
......@@ -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);
......
......@@ -2164,7 +2164,7 @@ function user_multiple_role_edit($accounts, $operation, $rid) {
}
function user_multiple_cancel_confirm(&$form_state) {
$edit = $form_state['post'];
$edit = $form_state['input'];
$form['accounts'] = array('#prefix' => '<ul>', '#suffix' => '</ul>', '#tree' => TRUE);
// array_filter() returns only elements with TRUE values.
......
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