function book_helper_form_alter in Book helper 6
Implementation of hook_form_alter().
File
- ./
book_helper.module, line 176 - Improves Drupal's core book module's functionality.
Code
function book_helper_form_alter(&$form, &$form_state, $form_id) {
if ($form['#id'] == 'node-form') {
$node =& $form['#node'];
$type = $form['type']['#value'];
if (isset($form['book']) && !book_type_is_allowed($type) && empty($node->book['bid'])) {
// Hide book fieldset.
$form['book']['#access'] = FALSE;
}
elseif (!isset($node->nid) && !isset($_GET['parent']) && in_array($type, variable_get('book_helper_create_new', array()))) {
// Create new book for selected nodes that are not being added as child pages.
$node->book['bid'] == 'new';
$form['book']['bid']['#default_value'] = 'new';
}
if (isset($form['book'])) {
// Define default book helper properties.
if (!isset($node->book_helper)) {
$node->book_helper = array(
'link_title_custom' => $node->title,
'link_title_sync' => TRUE,
);
}
// Add inputs to allow user to customize the book link title separately from the node's title.
drupal_add_js(drupal_get_path('module', 'book_helper') . '/book_helper.js');
$form['book']['book_helper_link_title_custom'] = array(
'#type' => 'textfield',
'#title' => t('Book link title'),
'#default_value' => $node->book_helper['link_title_custom'],
'#maxlength' => 255,
);
$form['book']['book_helper_link_title_sync'] = array(
'#type' => 'checkbox',
'#title' => t("Syncronize this node's title with its book link title."),
'#default_value' => $node->book_helper['link_title_sync'],
);
}
}
}