function fivestar_form_submit in Fivestar 6
Same name and namespace in other branches
- 5 fivestar.module \fivestar_form_submit()
- 6.2 fivestar.module \fivestar_form_submit()
- 7.2 fivestar.module \fivestar_form_submit()
Submit handler for the above form (non-javascript version).
1 string reference to 'fivestar_form_submit'
File
- ./
fivestar.module, line 1299 - A simple n-star voting widget, usable in other forms.
Code
function fivestar_form_submit($form, &$form_state) {
if ($form_state['values']['form_id'] == 'fivestar_form_' . $form_state['values']['content_type'] . '_' . $form_state['values']['content_id']) {
// Cast the vote.
_fivestar_cast_vote($form_state['values']['content_type'], $form_state['values']['content_id'], $form_state['values']['vote']);
votingapi_recalculate_results($form_state['values']['content_type'], $form_state['values']['content_id']);
// Set a message that the vote was received.
if ($form_state['values']['vote'] === '0') {
drupal_set_message(t('Your vote has been cleared.'));
}
elseif (is_numeric($form_state['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();
}
}