You are here

function answers_form in Answers 5.2

Same name and namespace in other branches
  1. 7.4 answers.module \answers_form()

Implementation of hook_form().

File

./answers.module, line 343
Enables the creation of question nodes that can be answered by posting answer nodes.

Code

function answers_form($form_values = NULL) {
  $node = $form_values;
  $type = node_get_types('type', 'answers');
  $form['title'] = array(
    '#type' => 'textfield',
    '#title' => check_plain($type->title_label),
    '#required' => TRUE,
    '#default_value' => $node->title,
    '#prefix' => '<div class="container-inline">',
    '#suffix' => '</div>',
    '#weight' => -5,
  );
  $form['body_filter']['body'] = array(
    '#type' => 'textarea',
    '#title' => check_plain($type->body_label),
    '#default_value' => $node->body,
    '#prefix' => '<div class="container-inline">',
    '#suffix' => '</div>',
    '#attributes' => array(
      'class' => 'mceNoEditor',
    ),
    '#required' => FALSE,
  );
  $form['body_filter']['filter'] = filter_form($node->format);
  if (variable_get('allow_answeranon', 0)) {
    $form['answeroptions']['answeranon'] = array(
      '#type' => 'checkbox',
      '#title' => t('Make this question anonymous (Hide my Profile)'),
      '#prefix' => '<div class="questpreview answeranon">',
      '#suffix' => '</div>',
      '#default_value' => $node->answeranon,
      '#weight' => 3,
      '#required' => FALSE,
    );
  }
  $form['answeroptions']['notifyme'] = array(
    '#type' => 'checkbox',
    '#title' => t('Notify me by email when I recieve new answers to this question'),
    '#prefix' => '<div class="questpreview notifyme">',
    '#suffix' => '</div>',
    '#default_value' => $node->notifyme,
    '#weight' => 3,
    '#required' => FALSE,
  );
  return $form;
}