When I use the comment widget to rate nodes out of the core comment modul and set the fivestar comment settings to "Require Rating", it is still possible to submit a comment without rating.

Is there a fix for this bug? Perhaps it is only a problem with the 6.x-1.12 Version.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

911’s picture

No fix for this bug? Any help is appriciated. Forcing user to give a vote while commenting is important for a simple review system with fivestar.

Best Regards

vladimir.dolgopolov’s picture

That's because of:

  $options = array('-' => t('Select rating'));

in fivestar.module.
Sign '-' lets a vote be valid.

vladimir.dolgopolov’s picture

It's strange fivestar_validate() should handle this sutuation but it never runs.

911’s picture

Hi vladimir,
thanks for your help.

That's because of:

<?php
  $options = array('-' => t('Select rating'));
?>

in fivestar.module.
Sign '-' lets a vote be valid.

What does that mean? Is there a way to fix this?

vladimir.dolgopolov’s picture

I'm searching the way.
It seems fivestar_validate() should definitely do that but it doesn't.

vladimir.dolgopolov’s picture

FileSize
1.12 KB

I think I've found the issue in fivestar.module:
Before:

$element['#validate']['fivestar_validate'] = array();

After:

$element['#element_validate'] = array('fivestar_validate');

The origin is http://api.drupal.org/api/file/developer/topics/forms_api_reference.html...

The patch is not fully tested.

vladimir.dolgopolov’s picture

Status: Active » Needs review

code needs review

vladimir.dolgopolov’s picture

FileSize
1.1 KB

Rerolled patch. Replaced $form_state with $element.

quicksketch’s picture

Status: Needs review » Fixed

Thanks vladimir! Nice catch, a lingering piece of un-upgraded code from the D5 version.

quicksketch’s picture

Title: "Requiered Rating" does not work » "Required Rating" does not work
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.