You are here

function fivestar_widget in Fivestar 6

Same name and namespace in other branches
  1. 5 fivestar_field.inc \fivestar_widget()
  2. 6.2 includes/fivestar.field.inc \fivestar_widget()

Implementation of hook_widget().

4 string references to 'fivestar_widget'
fivestar_add_css in ./fivestar.module
Fetch the necessary CSS files to render the fivestar widget.
fivestar_color_form_submit in ./fivestar_color.inc
Submit handler for color change form.
fivestar_settings in ./fivestar.module
Callback function for admin/settings/fivestar. Display the settings form.
fivestar_settings_submit in ./fivestar.module

File

./fivestar_field.inc, line 209
Provides CCK integration for fivestar module

Code

function fivestar_widget(&$form, &$form_state, $field, $items) {
  $element = array(
    '#tree' => TRUE,
  );
  $element['rating'] = array(
    '#type' => 'fivestar',
    '#title' => t($field['widget']['label']),
    '#default_value' => isset($items[0]['rating']) ? $items[0]['rating'] : NULL,
    '#stars' => is_numeric($field['stars']) ? $field['stars'] : 5,
    '#allow_clear' => $field['widget']['allow_clear'],
    '#description' => $field['widget']['description'],
    '#weight' => $field['widget']['weight'],
    '#auto_submit' => FALSE,
    '#widget' => $field['widget']['type'],
    '#required' => $field['required'],
    '#labels_enable' => FALSE,
  );
  $element['target'] = array(
    '#type' => 'value',
    '#value' => $field['target'],
  );
  $element['axis'] = array(
    '#type' => 'value',
    '#value' => $field['axis'],
  );

  // CCK likes to always have a 2D array for form elements.
  $element = array(
    $element,
  );
  return $element;
}