You are here

function rate_ui_widget_form in Rate 7.2

Implements hook_form().

Form callback for add or edit rate widget form.

1 string reference to 'rate_ui_widget_form'
rate_ui_menu in ui/rate_ui.module
Implements hook_menu().

File

ui/rate_ui.form.inc, line 12
This file contains the differtent Rate UI forms.

Code

function rate_ui_widget_form($form, &$form_state, $widget_type = NULL) {
  $step = isset($form_state['step']) ? $form_state['step'] : 1;
  $form['#step'] = $step;
  $form['#rate_wid'] = 0;
  $form['#rate_widget_name'] = $widget_type;
  if ($widget_type) {
    if (empty($form_state['storage'])) {
      $form_state['storage'] = array();
      $form['#rate_wid'] = rate_ui_widget_load_widget($widget_type, $form_state['storage']);
    }
    elseif (!empty($form_state['storage']['wid'])) {

      // Also set the wid when storage is not empty.
      $form['#rate_wid'] = $form_state['storage']['wid'];
    }
  }
  drupal_add_js(drupal_get_path('module', 'rate_ui') . '/admin.js', 'file');
  drupal_add_css(drupal_get_path('module', 'rate_ui') . '/admin.css');
  switch ($step) {
    case 1:
      $title = t('General settings');
      $form = rate_ui_widget_form_step_general($form, $form_state, $widget_type);
      break;
    case 2:
      $title = t('Voting buttons');
      $form = rate_ui_widget_form_step_buttons($form, $form_state, $widget_type);
      break;
    case 3:
      $title = t('Descriptions');
      $form = rate_ui_widget_form_step_descriptions($form, $form_state, $widget_type);
      break;
    case 4:
      $title = t('Theming options');
      $form = rate_ui_widget_form_step_theming($form, $form_state, $widget_type);
      break;
    case 5:
      $title = t('Images');
      $form = rate_ui_widget_form_step_images($form, $form_state, $widget_type);
      break;
    case 6:
      $title = t('Layout');
      $form = rate_ui_widget_form_step_layout($form, $form_state, $widget_type);
      break;
  }
  drupal_set_title(t('Step @step of @total: @title', array(
    '@step' => $step,
    '@total' => 6,
    '@title' => $title,
  )));
  return $form;
}