function fivestar_form_submit in Fivestar 5
Same name and namespace in other branches
- 6.2 fivestar.module \fivestar_form_submit()
- 6 fivestar.module \fivestar_form_submit()
- 7.2 fivestar.module \fivestar_form_submit()
Submit handler for the above form (non-javascript version).
File
- ./
fivestar.module, line 1230 - A simple n-star voting widget, usable in other forms.
Code
function fivestar_form_submit($form_id, $form_values) {
if ($form_id == 'fivestar_form_' . $form_values['content_type'] . '_' . $form_values['content_id']) {
// Cast the vote.
_fivestar_cast_vote($form_values['content_type'], $form_values['content_id'], $form_values['vote']);
votingapi_recalculate_results($form_values['content_type'], $form_values['content_id']);
// Set a message that the vote was received.
if ($form_values['vote'] === '0') {
drupal_set_message(t('Your vote has been cleared.'));
}
elseif (is_numeric($form_values['vote'])) {
drupal_set_message(t('Thank you for your vote.'));
}
// Regenerate the page with a drupal_goto() to update the current values.
drupal_goto();
}
}