You are here

function fivestar_form_submit in Fivestar 6.2

Same name and namespace in other branches
  1. 5 fivestar.module \fivestar_form_submit()
  2. 6 fivestar.module \fivestar_form_submit()
  3. 7.2 fivestar.module \fivestar_form_submit()

Submit handler for the above form (non-javascript version).

1 string reference to 'fivestar_form_submit'
fivestar_custom_widget in ./fivestar.module
Form builder; Build a custom Fivestar rating widget with arbitrary settings.

File

./fivestar.module, line 965
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'] . '_' . $form_state['values']['tag']) {

    // Cast the vote.
    _fivestar_cast_vote($form_state['values']['content_type'], $form_state['values']['content_id'], $form_state['values']['vote'], $form_state['values']['tag']);
    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();
  }
}