node_body_field

6 node.pages.inc node_body_field(&$node, $label, $word_count)

Return a node body field, with format and teaser.

4 calls to node_body_field()

File

modules/node/node.pages.inc, line 262
Page callbacks for adding, editing, deleting, and revisions management for content.

Code

function node_body_field(&$node, $label, $word_count) {

  // Check if we need to restore the teaser at the beginning of the body.
  $include = !isset($node->teaser) || ($node->teaser == substr($node->body, 0, strlen($node->teaser)));

  $form = array(
    '#after_build' => array('node_teaser_js', 'node_teaser_include_verify'),
  );

  $form['#prefix'] = '<div class="body-field-wrapper">';
  $form['#suffix'] = '</div>';

  $form['teaser_js'] = array(
    '#type' => 'textarea', 
    '#rows' => 10, 
    '#teaser' => 'edit-body', 
    '#teaser_checkbox' => 'edit-teaser-include', 
    '#disabled' => TRUE,
  );

  $form['teaser_include'] = array(
    '#type' => 'checkbox', 
    '#title' => t('Show summary in full view'), 
    '#default_value' => $include, 
    '#prefix' => '<div class="teaser-checkbox">', 
    '#suffix' => '</div>',
  );

  $form['body'] = array(
    '#type' => 'textarea', 
    '#title' => check_plain($label), 
    '#default_value' => $include ? $node->body : ($node->teaser . $node->body), 
    '#rows' => 20, 
    '#required' => ($word_count > 0),
  );

  $form['format'] = filter_form($node->format);

  return $form;
}
Login or register to post comments