function fivestar_form_comment_form_alter in Fivestar 7.2
Same name and namespace in other branches
- 8 fivestar.module \fivestar_form_comment_form_alter()
Implements hook_form_comment_form_alter().
This hook removes the parent node, together with the fivestar field, from the comment preview page. If this is left in, when the user presses the "Save" button after the preview page has been displayed, the fivestar widget gets the input rather than the comment; the user's input is lost. Based on a suggestion by ChristianAdamski in issue 1289832-3.
File
- ./
fivestar.module, line 390
Code
function fivestar_form_comment_form_alter(&$form, &$form_state, $form_id) {
$fivestar_field_keys = array();
if (isset($form['comment_output_below'])) {
foreach ($form['comment_output_below'] as $key => $value) {
if (is_array($value) && !empty($value['#field_type']) && $value['#field_type'] == 'fivestar') {
$fivestar_field_keys[] = $key;
}
}
}
if ($fivestar_field_keys) {
foreach ($fivestar_field_keys as $key) {
unset($form['comment_output_below'][$key]);
}
}
}