You are here

function theme_fivestar_preview_widget in Fivestar 8

Same name and namespace in other branches
  1. 5 fivestar.module \theme_fivestar_preview_widget()
  2. 6.2 includes/fivestar.admin.inc \theme_fivestar_preview_widget()
  3. 6 fivestar.module \theme_fivestar_preview_widget()
  4. 7.2 includes/fivestar.theme.inc \theme_fivestar_preview_widget()

Shows a preview of a widget using a custom CSS file.

1 string reference to 'theme_fivestar_preview_widget'
fivestar_theme in ./fivestar.module
Implements hook_theme().
2 theme calls to theme_fivestar_preview_widget()
FivestarFormatterBase::previewsExpand in src/Plugin/Field/FieldFormatter/FivestarFormatterBase.php
Prepares the widget's render element for rendering.
StarsWidget::previewsExpand in src/Plugin/Field/FieldWidget/StarsWidget.php
Prepares the widget's render element for rendering.

File

includes/fivestar.theme.inc, line 15
Provides the theming functions for fivestar.

Code

function theme_fivestar_preview_widget($variables) {

  //  $form = [
  //    '#post' => [],
  //    '#programmed' => FALSE,
  //    '#tree' => FALSE,
  //    '#parents' => [],
  //    '#array_parents' => [],
  //    '#required' => FALSE,
  //    '#attributes' => [],
  //    '#title_display' => 'before',
  //  ];
  //  $complete_form = [];
  //  $form_state = new FormState();
  //  $buidler = \Drupal::formBuilder();
  //  $form_state->setValues([]);
  //  $form_state->setProcessInput(FALSE);
  //  $form_state->setCompleteForm($complete_form);
  //  $form['vote'] = [
  //    '#type' => 'fivestar',
  //    '#stars' => 5,
  //    '#allow_clear' => TRUE,
  //    '#allow_revote' => TRUE,
  //    '#allow_ownvote' => TRUE,
  //    '#widget' => [
  //      'name' => isset($variables['name']) ? $variables['name'] : 'default',
  //      'css' => isset($variables['css']) && $variables['css'] != 'default' ? $variables['css'] : FALSE,
  //    ],
  //  ];
  //
  //  // Attach necessary JS settings.
  //  $settings = [
  //    'titleUser' => t('Your rating') . ': ',
  //    'titleAverage' => t('Average') . ': ',
  //    'feedbackSavingVote' => t('Saving your vote...'),
  //    'feedbackVoteSaved' => t('Your vote has been saved.'),
  //    'feedbackDeletingVote' => t('Deleting your vote...'),
  //    'feedbackVoteDeleted' => t('Your vote has been deleted.'),
  //  ];
  //  $form['#attached'][] = [
  //    'js' => [
  //      [
  //        'type' => 'setting',
  //        'data' => $settings,
  //      ],
  //    ],
  //  ];
  //
  //  $buidler->doBuildForm('fivestar_preview', $form, $form_state);
  //  $output = $form;
  //  $output['#prefix'] = '<div class="fivestar-star-preview fivestar-' . $form['vote']['#widget']['name'] . '">';
  //  $output['#suffix'] = '</div>';
  //
  //  return \Drupal::service('renderer')->render($output);
}