book_form_update

  1. drupal
    1. drupal6
    2. drupal7
Versionen
drupal6 – drupal7 book_form_update()

Renders a new parent page select element when the book selection changes.

This function is called via AJAX when the selected book is changed on a node or book outline form. It creates a new parent page select element, adds it to the cached form, and then returns the rendered element so it can be displayed on the form.

Rückgabewert

The rendered parent page select element.

Code

modules/book/book.pages.inc, line 229

<?php
function book_form_update() {
  $bid = $_POST['book']['bid'];
  if ($form = form_get_cache($_POST['form_build_id'], $form_state)) {

    // Validate the bid.
    if (isset($form['book']['bid']['#options'][$bid])) {
      $book_link = $form['#node']->book;
      $book_link['bid'] = $bid;
      // Get the new options and update the cache.
      $form['book']['plid'] = _book_parent_select($book_link);
      form_set_cache($_POST['form_build_id'], $form, $form_state);

      // Build and render the new select element, then return it in JSON format.
      $form_state = array();
      $form['#post'] = array();
      $form = form_builder($form['form_id']['#value'], $form, $form_state);
      $output = drupal_render($form['book']['plid']);
      drupal_json(array('status' => TRUE, 'data' => $output));
    }
    else {
      drupal_json(array('status' => FALSE, 'data' => ''));
    }
  }
  else {
    drupal_json(array('status' => FALSE, 'data' => ''));
  }
  exit();
}
?>

Kommentare

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen