Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I am trying to auto-assign book id (bid) on /node/add forms. I want to preselect the book so that the correct select element for pages populates on page load. I set:
$form['book']['#collapsed'] = 0;
$form['book']['bid']['#default_value'] = $project_nid;
$form['book']['bid']['#value'] = $project_nid;
The #collapsed worked so I am confident that I am altering the correct form. #value and #default_value do not have any effect. I was able to make some change in the display with:
function pm_content_input_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
switch( $op ) {
case 'prepare':
// Set $project_nid, code omitted
// Set parent project (book)
$node->book['original_bid'] = $project_nid;
$node->book['bid'] = $project_nid;
Comments