You are here

function faq_form in Frequently Asked Questions 5.2

Same name and namespace in other branches
  1. 5 faq.module \faq_form()
  2. 6 faq.module \faq_form()
  3. 7 faq.module \faq_form()

Defines the form where new questions and answers are written.

Parameters

&$node: The node object.

Return value

The form elements in the $form array.

File

./faq.module, line 177
The FAQ module allows users to create a FAQ page, with questions and answers displayed in different styles, according to the settings.

Code

function faq_form(&$node) {
  $type = node_get_types('type', $node);

  // Question.
  $form['title'] = array(
    '#type' => 'textarea',
    '#title' => t('Question'),
    '#default_value' => empty($node->question) ? $node->title : $node->question,
    '#required' => TRUE,
    '#weight' => -1,
    '#rows' => 3,
    '#description' => t('Question to be answered'),
  );

  // Answer.
  $form['body_filter']['body'] = array(
    '#type' => 'textarea',
    '#title' => t('Answer'),
    '#default_value' => $node->body,
    '#rows' => 20,
    '#weight' => 0,
    '#required' => TRUE,
    '#description' => t('This is that answer to the question.  It will be filtered according to the input format.'),
  );
  $form['body_filter']['format'] = filter_form($node->format);
  return $form;
}