You are here

public function FiveStarWidget::buildForm in Votingapi Widgets 8

Vote form.

Overrides VotingApiWidgetInterface::buildForm

File

src/Plugin/votingapi_widget/FiveStarWidget.php, line 30

Class

FiveStarWidget
Assigns ownership of a node to a user.

Namespace

Drupal\votingapi_widgets\Plugin\votingapi_widget

Code

public function buildForm($entity_type, $entity_bundle, $entity_id, $vote_type, $field_name, $settings) {
  $form = $this
    ->getForm($entity_type, $entity_bundle, $entity_id, $vote_type, $field_name, $settings);
  $build = [
    'rating' => [
      '#theme' => 'container',
      '#attributes' => [
        'class' => [
          'votingapi-widgets',
          'fivestar',
          $settings['readonly'] === 1 ? 'read_only' : '',
        ],
      ],
      '#children' => [
        'form' => $form,
      ],
    ],
    '#attached' => [
      'library' => [
        'votingapi_widgets/fivestar',
      ],
    ],
  ];
  return $build;
}