You are here

function commons_q_a_form_alter in Drupal Commons 7.3

Implements hook_form_alter().

File

modules/commons/commons_q_a/commons_q_a.module, line 215

Code

function commons_q_a_form_alter(&$form, &$form_state, $form_id) {

  // Unset the groups audience field. Answers programatically inherit
  // the group membership of their respective questions.
  if ($form_id == 'answer_node_form') {
    $form['og_group_ref']['#access'] = FALSE;
    $form['actions']['submit']['#submit'][] = 'commons_q_a_answer_submit';

    // Ensure that the answer node inherits group membership from the
    // parent question by preventing users from changing the audience through
    // the Trusted Contacts toggle when commons_trusted_contacts.module
    // is enabled.
    $form_state['hide_audience_toggle'] = TRUE;
  }
  if ($form_id == 'comment_node_question_form' || $form_id == 'comment_node_answer_form') {
    $form['container'] = array(
      '#type' => 'fieldset',
      '#title' => t('Add new comment'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
      '#weight' => 2,
    );
    $form['container']['author'] = $form['author'];
    $form['container']['comment_body'] = $form['comment_body'];
    $form['container']['actions'] = $form['actions'];
    unset($form['author']);
    unset($form['subject']);

    // We don't need a subject, they're pointless within comments.
    unset($form['comment_body']);
    unset($form['actions']);
  }
}