You are here

function fivestar_widget in Fivestar 5

Same name and namespace in other branches
  1. 6.2 includes/fivestar.field.inc \fivestar_widget()
  2. 6 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 197
Provides CCK integration for fivestar module

Code

function fivestar_widget($op, &$node, $field, &$items) {
  switch ($op) {
    case 'form':
      $form = array();
      $form[$field['field_name']] = array(
        '#tree' => TRUE,
      );
      $form[$field['field_name']][0]['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,
      );
      $form[$field['field_name']][0]['target'] = array(
        '#type' => 'value',
        '#value' => $field['target'],
      );
      $form[$field['field_name']][0]['axis'] = array(
        '#type' => 'value',
        '#value' => $field['axis'],
      );
      return $form;
  }
}