summaryrefslogtreecommitdiff
path: root/modules/node
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-09-09 23:01:48 +0000
committerDries Buytaert <dries@buytaert.net>2010-09-09 23:01:48 +0000
commiteaee909a00a516d864da65e44f8abe5446914c7e (patch)
treef3c52d3b9041e93a8e7000446016cc73b9413f2d /modules/node
parenta16c46bf8a99745d7fa31cc6f2c34e0b17e7bed6 (diff)
downloadbrdo-eaee909a00a516d864da65e44f8abe5446914c7e.tar.gz
brdo-eaee909a00a516d864da65e44f8abe5446914c7e.tar.bz2
- Patch #757154 by sun, effulgentsia: base form_id() via hook_forms() not taken into account for #validate, #submit, hook_form_FORMID_alter().
Diffstat (limited to 'modules/node')
-rw-r--r--modules/node/node.pages.inc18
1 files changed, 15 insertions, 3 deletions
diff --git a/modules/node/node.pages.inc b/modules/node/node.pages.inc
index 4053b6dc5..7a9e141bb 100644
--- a/modules/node/node.pages.inc
+++ b/modules/node/node.pages.inc
@@ -114,7 +114,9 @@ function node_form($form, &$form_state, $node) {
}
// Identify this as a node edit form.
+ // @todo D8: Remove. Modules can implement hook_form_BASE_FORM_ID_alter() now.
$form['#node_edit_form'] = TRUE;
+
$form['#attributes']['class'][] = 'node-form';
if (!empty($node->type)) {
$form['#attributes']['class'][] = 'node-' . $node->type . '-form';
@@ -136,6 +138,8 @@ function node_form($form, &$form_state, $node) {
);
// Invoke hook_form() to get the node-specific bits. Can't use node_invoke(),
// because hook_form() needs to be able to receive $form_state by reference.
+ // @todo hook_form() implementations are unable to add #validate or #submit
+ // handlers to the form buttons below. Remove hook_form() entirely.
$function = node_type_get_base($node) . '_form';
if (function_exists($function) && ($extra = $function($node, $form_state))) {
$form = array_merge_recursive($form, $extra);
@@ -143,9 +147,7 @@ function node_form($form, &$form_state, $node) {
if (!isset($form['title']['#weight'])) {
$form['title']['#weight'] = -5;
}
- // @todo Legacy support. Modules adding form building and processing functions
- // to the node form are encouraged to access the node using
- // $form_state['node']. Remove in Drupal 8.
+ // @todo D8: Remove. Modules should access the node using $form_state['node'].
$form['#node'] = $node;
$form['additional_settings'] = array(
@@ -281,7 +283,17 @@ function node_form($form, &$form_state, $node) {
'#submit' => array('node_form_delete_submit'),
);
}
+ // This form uses a button-level #submit handler for the form's main submit
+ // action. node_form_submit() manually invokes all form-level #submit handlers
+ // of the form. Without explicitly setting #submit, Form API would auto-detect
+ // node_form_submit() as submit handler, but that is the button-level #submit
+ // handler for the 'Save' action. To maintain backwards compatibility, a
+ // #submit handler is auto-suggested for custom node type modules.
$form['#validate'][] = 'node_form_validate';
+ if (!isset($form['#submit']) && function_exists($node->type . '_node_form_submit')) {
+ $form['#submit'][] = $node->type . '_node_form_submit';
+ }
+ $form += array('#submit' => array());
$form['#builder_function'] = 'node_form_submit_build_node';
field_attach_form('node', $node, $form, $form_state, $node->language);