You are here

function rate_choose_template_form in Rate 6.2

Same name and namespace in other branches
  1. 7 rate.admin.inc \rate_choose_template_form()

Form for choosing a template before the user goes to the add widget form.

2 string references to 'rate_choose_template_form'
rate_admin_page in ./rate.admin.inc
Menu callback.
rate_menu in ./rate.module
Implements hook_menu().

File

./rate.admin.inc, line 59
Rating admin

Code

function rate_choose_template_form(&$form_state, $id = NULL) {
  $form = array();
  if ($id) {
    $form['#widget_id'] = $id;
    $widgets = variable_get(RATE_VAR_WIDGETS, array());
    $widget = $widgets[$id];
    isset($widget->template) or $widget->template = 'custom';
    $selected = $widget->template;
  }
  else {
    $selected = 'custom';
  }
  $options = array(
    'custom' => t('Custom'),
  );
  foreach (module_implements('rate_templates') as $module) {
    foreach (module_invoke($module, 'rate_templates') as $name => $widget) {
      $options[$name] = $widget->template_title;
    }
  }
  $form['template'] = array(
    '#type' => 'select',
    '#title' => t('Widget type'),
    '#options' => $options,
    '#default_value' => $selected,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Next'),
  );
  return $form;
}