You are here

public function FivestarFormatterBase::previewsExpand in Fivestar 8

Prepares the widget's render element for rendering.

Parameters

array $element: The element to transform.

Return value

array The transformed element.

See also

::formElement()

File

src/Plugin/Field/FieldFormatter/FivestarFormatterBase.php, line 75

Class

FivestarFormatterBase
Base class for Fivestar field formatters.

Namespace

Drupal\fivestar\Plugin\Field\FieldFormatter

Code

public function previewsExpand(array $element) {
  foreach (Element::children($element) as $css) {
    $vars = [
      '#theme' => 'fivestar_preview_widget',
      '#css' => $css,
      '#name' => mb_strtolower($element[$css]['#title']),
    ];
    $element[$css]['#description'] = \Drupal::service('renderer')
      ->render($vars);
  }
  return $element;
}