book_form_alter
modules/book/book.module, строка 283
- Версии
- 6
book_form_alter(&$form, $form_state, $form_id)
Implementation of hook_form_alter()
. Adds the book fieldset to the node form.
See also
book_pick_book_submit()
@see book_submit()
Код
<?php
function book_form_alter(&$form, $form_state, $form_id) {
if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] .'_node_form' == $form_id) {
// Add elements to the node form
$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, $node);
$form['book']['pick-book'] = array(
'#type' => 'submit',
'#value' => t('Change book (update list of parents)'),
// Submit the node form so the parent select options get updated.
// This is typically only used when JS is disabled. Since the parent options
// won't be changed via AJAX, a button is provided in the node form to submit
// the form and generate options in the parent select corresponding to the
// selected book. This is similar to what happens during a node preview.
'#submit' => array('node_form_submit_build_node'),
'#weight' => 20,
);
}
}
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии