function faq_form in Frequently Asked Questions 6
Same name and namespace in other branches
- 5.2 faq.module \faq_form()
- 5 faq.module \faq_form()
- 7 faq.module \faq_form()
Defines the form where new questions and answers are written.
Parameters
&$node: The node being added or edited.
&$param: The hook can set this variable to an associative array of attributes to add to the enclosing <form> tag.
Return value
The form elements in the $form array.
File
- ./
faq.module, line 209 - 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, &$param) {
$type = node_get_types('type', $node);
// Short question.
$form['title'] = array(
'#type' => 'textfield',
'#title' => check_plain($type->title_label),
'#default_value' => $node->title,
'#required' => TRUE,
'#weight' => -2,
'#description' => t('Question to be answered. This will appear in all question listings, such as the FAQ blocks.'),
'#maxlength' => 255,
);
// Detailed question.
if (variable_get('faq_question_long_form', 1) || variable_get('faq_question_length', 'short') == 'long') {
$form['detailed_question'] = array(
'#type' => 'textarea',
'#title' => t('Question details (optional)'),
'#default_value' => isset($node->detailed_question) ? $node->detailed_question : '',
'#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'detailed_question') : -1,
'#rows' => 3,
'#description' => t('Longer question text. This will be displayed in all layouts where the answer appears, in addition to the shorter question text.'),
);
}
// Answer.
if (!empty($type->body_label)) {
$form['body_field'] = node_body_field($node, $type->body_label, $type->min_word_count);
$form['body_field']['body']['#description'] = t('This is that answer to the question. It will be filtered according to the input format.');
}
return $form;
}