You are here

function answers_form_question_node_form_alter in Answers 7.3

Same name and namespace in other branches
  1. 6.2 answers.module \answers_form_question_node_form_alter()

Implements hook_form_FORM_ID_alter() for question_node_form().

File

./answers.module, line 236

Code

function answers_form_question_node_form_alter(&$form, &$form_state) {
  $new = !isset($form_state['node']->nid) || isset($form_state['node']->is_new);
  if ($new) {
    $text = t('!answers_question_create_button_text', answers_translation());
  }
  else {
    $text = t('!answers_question_edit_button_text', answers_translation());
  }
  $form['actions']['submit']['#value'] = $text;

  // Populate title field if passed via URL if access to edit title.
  if (isset($_GET['title']) && (!isset($form['#access']) || !empty($form['#access']))) {
    drupal_set_title(t('Add some details to your question'));
    $form['title']['#default_value'] = $_GET['title'];
  }

  // Set a default value for 'field_answer_count'
  // (see https://drupal.org/node/2032121)
  $form['#submit'][] = 'answers_question_form_submit';

  // Hide 'field_best_answer' (this is only used behind the scenes, not directly
  // set by users)
  // This is required here instead of Best_Answer because this field can be
  // "left behind" if
  // Best_Answer is installed then uninstalled.
  $form['field_best_answer']['#prefix'] = '<div style="display: none;">';
  $form['field_best_answer']['#suffix'] = '</div>';
}