function answers_form_alter in Answers 5.2
Same name and namespace in other branches
- 6 answers.module \answers_form_alter()
- 7.4 answers.module \answers_form_alter()
- 7 answers.module \answers_form_alter()
- 7.2 answers.module \answers_form_alter()
File
- ./
answers.module, line 321 - Enables the creation of question nodes that can be answered by posting answer nodes.
Code
function answers_form_alter($form_id, &$form) {
$answertypes = module_invoke_all('answers', 'answersinfo');
foreach ($answertypes as $type => $name) {
if ($form_id == $type . '_node_form' || $form_id == $type . '_form' || $form_id == 'node_form') {
if (arg(0) == 'node' && arg(1) == 'add' && arg(3)) {
$nid = (int) arg(3);
}
else {
$nid = answers_answersapi('question', $form['nid']['#value']);
}
$form['questid'] = array(
'#type' => 'hidden',
'#value' => $nid,
);
$form['#redirect'] = 'node/' . $nid;
}
}
}