Drupal - Attach a 5-star widget to a custom form

  $path = drupal_get_path('module', 'fivestar');      
  drupal_add_js($path . '/js/fivestar.js');
  drupal_add_css($path . '/css/fivestar.css');

  $rating = votingapi_select_single_result_value(array(
        'entity_id' => YOURENTITY_ID,
        'entity_type' => 'YOURENTITY_TYPE',
        'tag' => 'vote',
        'function' => 'average',
   ));
   $form['votes'] = array(
      '#markup' =>  theme('fivestar_static', array('rating' => $rating, 'stars' => 5, 'tag' => 'vote')),
   );

It can be done using the following code.

$form['presentation_ratting'] = array(
  '#type' => 'fivestar',
  '#stars' => 5,
  '#title' => t('Presentation.'),
);

Tags:

Rating

7