- Issue created by @msypes
Creating a fivestar widget with less than five stars can be a multistep process, because you cannot, as the Options description says, If you do so on more than one option at a time, it will trigger Drupal\rate\RateWidgetForm::ValidateForm()'s
call to $form_state->setError()
with
You can get around the issue by deleting one at a time, but that really shouldn't be necessary.
Try creating a new Fivestar Rate widget at /admin/structure/rate/add
with less than four stars by following the description text and deleting the label and value from two or more options.
The form will fail validation and output the error message
You can delete one option at time, coming back to resave after each.
This looks to me like the code introduced from
https://www.drupal.org/project/rate/issues/3267488 β
went a little too far:
I also got around the issue by adding conditions to the if
statement (line 710) surrounding the $form_state->setError()
, changing it from if ($settings['value'] == $value){
to if ($settings['value'] == $value && !empty($settings['label']) && $value != '') {
, but I doubt this is a proper long-term solution, as I don't know how this change would affect other situations, and Drupal now has proper Form Validation classes which probably offer better paths to follow.
Active
3.1
Code