function rate_ui_widget_form_submit in Rate 7.2
Implements hook_form_submit().
Submit handler for the rate widget form.
1 string reference to 'rate_ui_widget_form_submit'
- rate_ui_widget_form_step_buttons in ui/
rate_ui.form.inc - Generate form fields for the second step in the rate widget form.
File
- ui/
rate_ui.form.inc, line 655 - This file contains the differtent Rate UI forms.
Code
function rate_ui_widget_form_submit($form, &$form_state) {
$form_state['storage'] = isset($form_state['storage']) ? $form_state['storage'] : array();
$form_state['storage'] = array_merge($form_state['storage'], $form_state['values']);
// This var is set to TRUE when we are ready to save the widget.
$save = FALSE;
// We can skip step 5 if we don't use images.
// The next step is step 6 when we are on step 4 and clicking "next" or
// when we are on step 6 and clicking "previous".
if ($form['#step'] == 4 && $form_state['triggering_element']['#id'] == 'edit-next' || $form['#step'] == 6 && $form_state['triggering_element']['#id'] == 'edit-previous') {
if (!$form_state['storage']['images']) {
// We use text links.
$form['#step'] += $form_state['triggering_element']['#id'] == 'edit-previous' ? -1 : 1;
}
}
switch ($form_state['triggering_element']['#id']) {
case 'edit-next':
$form_state['step'] = $form['#step'] + 1;
break;
case 'edit-previous':
$form_state['step'] = $form['#step'] - 1;
break;
case 'edit-submit':
$save = TRUE;
break;
}
if ($save) {
if ($wid = rate_ui_widget_save_widget($form['#rate_wid'], $form_state['storage'])) {
rate_ui_widget_save_buttons($wid, $form_state['storage']);
rate_ui_widget_save_layout($wid, $form_state['storage']);
drupal_set_message(t('The widget has been saved succesfully.'));
}
else {
drupal_set_message(t('The widget could not be saved.'), 'error');
}
$form_state['redirect'] = 'admin/structure/rate';
}
else {
$form_state['rebuild'] = TRUE;
}
}