function new_faq_form in Frequently Asked Questions 7.2
Implements hook_form().
@todo 7.x-2.x remove for field api
Parameters
&$node object: The node being added or edited.
&$form_state array: The hook can set this variable to an associative array of attributes to add to the enclosing <form> tag.
Return value
array The form elements in the $form array.
File
- ./
faq.module, line 227 - The FAQ module allows users to create a FAQ page, with questions and answers displayed in different styles, according to the settings.
Code
function new_faq_form($node, $form_state) {
$type = node_type_get_type($node);
// Set defaults.
if (empty($node->detailed_question)) {
$node->detailed_question = '';
}
$form = node_content_form($node, $form_state);
$form['title']['#description'] = t('Question to be answered. This will appear in all question listings, such as the FAQ blocks.');
// 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'),
'#default_value' => $node->detailed_question,
'#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)) {
field_attach_form('node', $node, $form, $form_state, $node->language);
}
return $form;
}