Placing this in a custom module that is creating a block. When rendering the code below I get a "Fatal error: Unsupported operand types in C:\wamp\www\example.com\sites\all\modules\contrib\fivestar\includes\fivestar.theme.inc on line 271".

I have more than one of these ratings being displayed. Right now -- none of these have votes.

$term_data = taxonomy_term_load($data['entity_id']);
$settings = array(
    'content_type' => 'taxonomy',
    'content_id' => $term_data->tid,
    'entity' => $term_data,
    'stars' => 5,
    'field_name' => 'field_user_rating',
    'autosubmit' => TRUE,
    'allow_clear' => FALSE,
    'allow_revote' => FALSE,
    'langcode' => 'en',
    'text' => 'average', // options are none, average, smart, user, and dual
    'tag' => 'user rating',
    'style' => 'average', // options are average, dual, smart, user
    'widget' => array( 'name' => 'basic', 'css' => drupal_get_path('module', 'fivestar') . '/widgets/basic/basic.css' )
    );
global $user;
$fivestar_values = fivestar_get_votes('taxonomy', $term_data->tid, 'user rating', $user->uid);
print render(drupal_get_form('fivestar_custom_widget', $fivestar_values, $settings));

It's trying to pass an empty array for the $average_rating on line 271 of fivestar.theme.inc.

The code that implements this is in the fivestar_expand function on line 552 of fivestar.module.

If I use "none" instead of "average" in the settings array it works fine.

To fix: Simply need to account for an array being passed so it doesn't try to multiply it by the number of stars.

Comments

nDigitHQ’s picture

Issue summary: View changes
shkiper’s picture

Could you please try this solution to display fivestar widget?
http://drupal.stackexchange.com/questions/25916/using-fivestar-get-votes...

dbt102’s picture

Please test with 7.x-2.2 release and report back, as there have been a lot of fixes applied since then.

TR’s picture

Status: Active » Closed (cannot reproduce)

No further information provided.