function answers_form_answer_node_form_alter in Answers 7.3
Same name and namespace in other branches
- 6.2 answers.module \answers_form_answer_node_form_alter()
Implements hook_form_FORM_ID_alter() for answer_node_form().
File
- ./
answers.module, line 276
Code
function answers_form_answer_node_form_alter(&$form, &$form_state) {
$new = !isset($form_state['node']->nid) || isset($form_state['node']->is_new);
if ($new) {
$text = t('!answers_answer_create_button_text', answers_translation());
}
else {
$text = t('!answers_answer_edit_button_text', answers_translation());
}
$form['actions']['submit']['#value'] = $text;
// If setting enabled, set nodereference to answer node, so that answer can be
// linked to question.
if (variable_get('answers_hide_question_reference_field', TRUE)) {
$node = menu_get_object();
if ($node && $node->type == 'question') {
$form_state['storage']['answers_question'] = $node->nid;
}
$form['field_answer_question']['#access'] = FALSE;
array_unshift($form['actions']['submit']['#submit'], 'answers_assign_question_reference');
}
// 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_p']['#prefix'] = '<div style="display: none;">';
$form['field_best_answer_p']['#suffix'] = '</div>';
}