Issue #1162022 by sun: Ensure #validate and #submit keys always exist in drupal_prepare_form().

8.0.x
webchick 2011-07-04 10:11:33 -07:00
parent 95b5e98fd9
commit 722e19482d
1 changed files with 4 additions and 0 deletions

View File

@ -995,6 +995,8 @@ function drupal_prepare_form($form_id, &$form, &$form_state) {
$form += array('#tree' => FALSE, '#parents' => array());
if (!isset($form['#validate'])) {
// Ensure that modules can rely on #validate being set.
$form['#validate'] = array();
// Check for a handler specific to $form_id.
if (function_exists($form_id . '_validate')) {
$form['#validate'][] = $form_id . '_validate';
@ -1007,6 +1009,8 @@ function drupal_prepare_form($form_id, &$form, &$form_state) {
}
if (!isset($form['#submit'])) {
// Ensure that modules can rely on #submit being set.
$form['#submit'] = array();
// Check for a handler specific to $form_id.
if (function_exists($form_id . '_submit')) {
$form['#submit'][] = $form_id . '_submit';