function book_form_node_form_alter
Same name in other branches
- 9 core/modules/book/book.module \book_form_node_form_alter()
- 8.9.x core/modules/book/book.module \book_form_node_form_alter()
- 10 core/modules/book/book.module \book_form_node_form_alter()
- 11.x core/modules/book/book.module \book_form_node_form_alter()
Implements hook_form_BASE_FORM_ID_alter() for node_form().
Adds the book fieldset to the node form.
See also
File
-
modules/
book/ book.module, line 419
Code
function book_form_node_form_alter(&$form, &$form_state, $form_id) {
$node = $form['#node'];
$access = user_access('administer book outlines');
if (!$access) {
if (user_access('add content to books') && (!empty($node->book['mlid']) && !empty($node->nid) || book_type_is_allowed($node->type))) {
// Already in the book hierarchy, or this node type is allowed.
$access = TRUE;
}
}
if ($access) {
_book_add_form_elements($form, $form_state, $node);
// Since the "Book" dropdown can't trigger a form submission when
// JavaScript is disabled, add a submit button to do that. book.css hides
// this button when JavaScript is enabled.
$form['book']['pick-book'] = array(
'#type' => 'submit',
'#value' => t('Change book (update list of parents)'),
'#submit' => array(
'book_pick_book_nojs_submit',
),
'#weight' => 20,
);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.