only in patch2: unchanged: --- a/composer.json +++ b/composer.json @@ -9,7 +9,6 @@ "source": "https://git.drupalcode.org/project/fivestar" }, "require": { - "drupal/core": "^8.8.2 || ^9", "drupal/votingapi": "^3.0" }, "minimum-stability": "dev" only in patch2: unchanged: --- a/fivestar.info.yml +++ b/fivestar.info.yml @@ -2,8 +2,7 @@ name: Fivestar type: module description: 'Enables fivestar ratings on content, users, etc.' package: Voting -core_version_requirement: ^8.8.2 || ^9 +core_version_requirement: ^9.3 || ^10 dependencies: - votingapi:votingapi - configure: fivestar.admin_overview only in patch2: unchanged: --- a/fivestar.libraries.yml +++ b/fivestar.libraries.yml @@ -9,7 +9,7 @@ fivestar.base: dependencies: - core/jquery - core/drupal - - core/jquery.once + - core/once - core/drupal.ajax fivestar.admin: @@ -25,7 +25,7 @@ fivestar.ajax: dependencies: - core/jquery - core/drupal - - core/jquery.once + - core/once # Widgets # Right now does not include RTL handling only in patch2: unchanged: --- a/src/Element/Fivestar.php +++ b/src/Element/Fivestar.php @@ -262,10 +262,10 @@ class Fivestar extends FormElement { // Check if user have votes in current entity type. $vote_ids = []; $current_user = \Drupal::currentUser(); - $entity_type = isset($element['#settings']['content_type']) ? $element['#settings']['content_type'] : NULL; - $entity_id = isset($element['#settings']['content_id']) ? $element['#settings']['content_id'] : NULL; + $entity_type = isset($element['#settings']['entity_type']) ? $element['#settings']['entity_type'] : NULL; + $entity_id = isset($element['#settings']['entity_id']) ? $element['#settings']['entity_id'] : NULL; - if (!$entity_type || !$entity_id) { + if ($entity_type && $entity_id) { $vote_ids = \Drupal::entityQuery('vote') ->condition('entity_type', $entity_type) ->condition('entity_id', $entity_id) @@ -274,7 +274,7 @@ class Fivestar extends FormElement { } // If user voted before, return FALSE. - if (empty($vote_ids)) { + if (!empty($vote_ids)) { return FALSE; } only in patch2: unchanged: --- a/src/Form/FivestarForm.php +++ b/src/Form/FivestarForm.php @@ -62,6 +62,11 @@ class FivestarForm extends FormBase { $field_name = $field_definition->getName(); $voting_is_allowed = (bool) ($field_settings['rated_while'] == 'viewing'); + // Extend display settings by entity_type and id. + $settings = $context['display_settings']; + $settings['entity_type'] = $entity->getEntityTypeId(); + $settings['entity_id'] = $entity->id(); + $form['vote'] = [ '#type' => 'fivestar', '#stars' => $field_settings['stars'], @@ -72,7 +77,7 @@ class FivestarForm extends FormBase { '#widget' => $context['display_settings'], '#default_value' => $entity->get($field_name)->rating, '#values' => $this->resultManager->getResultsByVoteType($entity, $field_settings['vote_type']), - '#settings' => $context['display_settings'], + '#settings' => $settings, '#show_static_result' => !$voting_is_allowed, '#attributes' => [ 'class' => ['vote'],