function book_form_node_form_alter in Drupal 7
Same name and namespace in other branches
- 8 core/modules/book/book.module \book_form_node_form_alter()
- 9 core/modules/book/book.module \book_form_node_form_alter()
- 10 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 - Allows users to create and organize related content in an outline.
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,
);
}
}