Community Documentation

comment_update_7005

7 comment.install comment_update_7005()

Create the comment_body field.

File

modules/comment/comment.install, line 239
Install, update and uninstall functions for the comment module.

Code

<?php
function comment_update_7005() {
  // Create comment body field.
  $field = array(
    'field_name' => 'comment_body', 
    'type' => 'text_long', 
    'module' => 'text', 
    'entity_types' => array(
      'comment',
    ), 
    'settings' => array(), 
    'cardinality' => 1,
  );
  _update_7000_field_create_field($field);

  // Add the field to comments for all existing bundles.
  $generic_instance = array(
    'entity_type' => 'comment', 
    'label' => t('Comment'), 
    'settings' => array(
      'text_processing' => 1,
    ), 
    'required' => TRUE, 
    'display' => array(
      'default' => array(
        'label' => 'hidden', 
        'type' => 'text_default', 
        'weight' => 0, 
        'settings' => array(), 
        'module' => 'text',
      ),
    ), 
    'widget' => array(
      'type' => 'text_textarea', 
      'settings' => array(
        'rows' => 5,
      ), 
      'weight' => 0, 
      'module' => 'text',
    ), 
    'description' => '',
  );

  $types = _update_7000_node_get_types();
  foreach ($types as $type => $type_object) {
    $instance = $generic_instance;
    $instance['bundle'] = 'comment_node_' . $type;
    _update_7000_field_create_instance($field, $instance);
  }
}
?>
Login or register to post comments