- Patch #49799: fixed form goto problem (Today's critical bugfix #1.)
parent
688197e8cd
commit
f29e0405f4
|
@ -103,23 +103,23 @@ function drupal_get_form($form_id, &$form, $callback = NULL) {
|
|||
}
|
||||
|
||||
$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);
|
||||
if ($form_submitted && !form_get_errors()) {
|
||||
$redirect = drupal_submit_form($form_id, $form, $callback);
|
||||
if (!is_null($redirect)) {
|
||||
if (isset($redirect)) {
|
||||
$goto = $redirect;
|
||||
}
|
||||
else if ($form['#redirect']) {
|
||||
elseif (isset($form['#redirect'])) {
|
||||
$goto = $form['#redirect'];
|
||||
}
|
||||
|
||||
if ($goto !== FALSE) {
|
||||
if (is_array($goto)) {
|
||||
call_user_func_array('drupal_goto', $redirect);
|
||||
}
|
||||
else {
|
||||
drupal_goto(drupal_get_path_alias($goto));
|
||||
drupal_goto($goto);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -149,14 +149,15 @@ function drupal_validate_form($form_id, &$form, $callback = NULL) {
|
|||
function drupal_submit_form($form_id, $form, $callback = NULL) {
|
||||
global $form_values;
|
||||
|
||||
$goto = null;
|
||||
unset($GLOBALS['form_values']['submit'], $GLOBALS['form_values']['form_id']);
|
||||
if (isset($form['#submit'])) {
|
||||
foreach ($form['#submit'] as $function => $args) {
|
||||
if (function_exists($function)) {
|
||||
// Since we can only redirect to one page, only the last redirect will work
|
||||
$redirect = call_user_func_array($function, $args);
|
||||
$goto = (!is_null($redirect)) ? $redirect : $goto;
|
||||
if (isset($redirect)) {
|
||||
$goto = $redirect;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@ function _locale_admin_manage_screen() {
|
|||
$languages = locale_supported_languages(TRUE, TRUE);
|
||||
|
||||
$options = array();
|
||||
$form['#action'] = url('admin/locale');
|
||||
$form['name'] = array('#tree' => TRUE);
|
||||
foreach ($languages['name'] as $key => $lang) {
|
||||
$options[$key] = '';
|
||||
|
@ -67,10 +66,10 @@ function _locale_admin_manage_screen() {
|
|||
$form['sitedefault'] = array('#type' => 'radios', '#options' => $options, '#default_value' => $isdefault, '#return_value' => 1);
|
||||
$form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
|
||||
|
||||
return drupal_get_form('_locale_admin_manage_screen', $form);
|
||||
return drupal_get_form('_locale_admin_manage_screen', $form, 'locale_admin_manage_screen');
|
||||
}
|
||||
|
||||
function theme__locale_admin_manage_screen($form) {
|
||||
function theme_locale_admin_manage_screen($form) {
|
||||
foreach ($form['name'] as $key => $element) {
|
||||
// Don't take form control structures
|
||||
if (is_array($element) && element_child($key)) {
|
||||
|
@ -1137,7 +1136,7 @@ function _locale_string_seek_form() {
|
|||
$form['search']['language'] = array('#type' => 'radios', '#title' => t('Language'), '#default_value' => ($query->language ? $query->language : 'all'), '#options' => array_merge(array('all' => t('All languages'), 'en' => t('English (provided by Drupal)')), $languages['name']));
|
||||
$form['search']['searchin'] = array('#type' => 'radios', '#title' => t('Search in'), '#default_value' => ($query->searchin ? $query->searchin : 'all'), '#options' => array('all' => t('All strings in that language'), 'translated' => t('Only translated strings'), 'untranslated' => t('Only untranslated strings')));
|
||||
$form['search']['submit'] = array('#type' => 'submit', '#value' => t('Search'));
|
||||
$form['#action'] = url('admin/locale/string/search');
|
||||
$form['#redirect'] = FALSE;
|
||||
|
||||
return drupal_get_form('_locale_string_seek', $form);
|
||||
}
|
||||
|
|
|
@ -990,9 +990,7 @@ function search_form($action = '', $keys = '', $type = null, $prompt = null) {
|
|||
$prompt = t('Enter your keywords');
|
||||
}
|
||||
|
||||
$form = array();
|
||||
$form['#action'] = $action;
|
||||
$form['#attributes'] = array('class' => 'search-form');
|
||||
$form = array('#action' => $action, '#attributes' => array('class' => 'search-form'), '#redirect' => FALSE);
|
||||
$form['basic'] = array('#type' => 'item', '#title' => $prompt);
|
||||
$form['basic']['inline'] = array('#type' => 'markup', '#prefix' => '<div class="container-inline">', '#suffix' => '</div>');
|
||||
$form['basic']['inline']['keys'] = array('#type' => 'textfield', '#title' => '', '#default_value' => $keys, '#size' => $prompt ? 40 : 20, '#maxlength' => 255);
|
||||
|
|
|
@ -990,9 +990,7 @@ function search_form($action = '', $keys = '', $type = null, $prompt = null) {
|
|||
$prompt = t('Enter your keywords');
|
||||
}
|
||||
|
||||
$form = array();
|
||||
$form['#action'] = $action;
|
||||
$form['#attributes'] = array('class' => 'search-form');
|
||||
$form = array('#action' => $action, '#attributes' => array('class' => 'search-form'), '#redirect' => FALSE);
|
||||
$form['basic'] = array('#type' => 'item', '#title' => $prompt);
|
||||
$form['basic']['inline'] = array('#type' => 'markup', '#prefix' => '<div class="container-inline">', '#suffix' => '</div>');
|
||||
$form['basic']['inline']['keys'] = array('#type' => 'textfield', '#title' => '', '#default_value' => $keys, '#size' => $prompt ? 40 : 20, '#maxlength' => 255);
|
||||
|
|
Loading…
Reference in New Issue