You are here

function rate_ui_widget_form_step_general in Rate 7.2

Generate form fields for the first step in the rate widget form.

1 call to rate_ui_widget_form_step_general()
rate_ui_widget_form in ui/rate_ui.form.inc
Implements hook_form().

File

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

Code

function rate_ui_widget_form_step_general($form, &$form_state, $widget_type = NULL) {
  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Name'),
    '#default_value' => isset($form_state['storage']['name']) ? $form_state['storage']['name'] : NULL,
    '#required' => TRUE,
  );
  $form['type'] = array(
    '#type' => 'machine_name',
    '#default_value' => isset($form_state['storage']['type']) ? $form_state['storage']['type'] : NULL,
    '#maxlength' => 32,
    '#disabled' => !empty($widget_type),
    '#machine_name' => array(
      'exists' => '_rate_get_widgets',
    ),
    '#description' => t('A unique machine-readable name for this widget. It must only contain lowercase letters, numbers, and underscores.'),
  );
  $metadata = votingapi_metadata();
  $options = array();
  foreach ($metadata['value_types'] as $value_type => $info) {
    $options[$value_type] = $info['name'];
  }
  $form['mode'] = array(
    '#type' => 'radios',
    '#title' => t('VotingAPI mode'),
    '#options' => $options,
    '#default_value' => isset($form_state['storage']['mode']) ? $form_state['storage']['mode'] : NULL,
    '#required' => TRUE,
  );
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['next'] = array(
    '#type' => 'submit',
    '#value' => t('Next'),
  );
  return $form;
}