comment_form_alter

  1. drupal
    1. 4.7
    2. 5 comment.module
    3. 6 comment.module
Versions
4.7 – 5 comment_form_alter($form_id, &$form)
6 comment_form_alter(&$form, $form_state, $form_id)

Code

modules/comment.module, line 241

<?php
function comment_form_alter($form_id, &$form) {
  if (isset($form['type'])) {
    if ($form['type']['#value'] . '_node_settings' == $form_id) {
      $form['workflow']['comment_' . $form['type']['#value']] = array(
        '#type' => 'radios',
        '#title' => t('Default comment setting'),
        '#default_value' => variable_get('comment_' . $form['type']['#value'], COMMENT_NODE_READ_WRITE),
        '#options' => array(t('Disabled'), t('Read only'), t('Read/Write')),
        '#description' => t('Users with the <em>administer comments</em> permission will be able to override this setting.'),
      );
    }
    if ($form['type']['#value'] . '_node_form' == $form_id) {
      $node = $form['#node'];
      if (user_access('administer comments')) {
        $form['comment_settings'] = array(
          '#type' => 'fieldset', 
          '#title' => t('Comment settings'), 
          '#collapsible' => TRUE, 
          '#collapsed' => TRUE, 
          '#weight' => 30,
        );
        $form['comment_settings']['comment'] = array(
          '#type' => 'radios', 
          '#parents' => array('comment'), 
          '#default_value' => $node->comment, 
          '#options' => array(t('Disabled'), t('Read only'), t('Read/Write')),
        );
      }
      else {
        $form['comment_settings']['comment'] = array(
          '#type' => 'value', 
          '#value' => $node->comment,
        );
      }
    }
  }
}
?>