You are here

public function MdStarRatingWidget::settingsForm in Star Rating Form Display 8

Returns a form to configure settings for the widget.

Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase to allow administrators to configure the widget. The field_ui module takes care of handling submitted form values.

Parameters

array $form: The form where the settings form is being included in.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form definition for the widget settings.

Overrides WidgetBase::settingsForm

File

src/Plugin/Field/FieldWidget/MdStarRatingWidget.php, line 84

Class

MdStarRatingWidget
Plugin implementation of the 'starrating' widget.

Namespace

Drupal\starrating_formdisplay\Plugin\Field\FieldWidget

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  global $base_url;
  $element = [];
  $element['icon_type'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Icon type'),
    '#options' => [
      'star' => $this
        ->t('Star'),
      'starline' => $this
        ->t('Star (outline)'),
      'check' => $this
        ->t('Check'),
      'heart' => $this
        ->t('Heart'),
      'dollar' => $this
        ->t('Dollar'),
      'smiley' => $this
        ->t('Smiley'),
      'food' => $this
        ->t('Food'),
      'coffee' => $this
        ->t('Coffee'),
      'movie' => $this
        ->t('Movie'),
      'music' => $this
        ->t('Music'),
      'human' => $this
        ->t('Human'),
      'thumbsup' => $this
        ->t('Thumbs Up'),
      'car' => $this
        ->t('Car'),
      'airplane' => $this
        ->t('Airplane'),
      'fire' => $this
        ->t('Fire'),
      'drupalicon' => $this
        ->t('Drupalicon'),
      'custom' => $this
        ->t('Custom'),
    ],
    '#default_value' => $this
      ->getSetting('icon_type'),
    '#prefix' => '<img src="' . $base_url . '/' . drupal_get_path('module', 'starrating') . '/css/sample.png" />',
  ];
  $element['icon_color'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Icon color'),
    '#options' => [
      1 => '1',
      2 => '2',
      3 => '3',
      4 => '4',
      5 => '5',
      6 => '6',
      7 => '7',
      8 => '8',
    ],
    '#default_value' => $this
      ->getSetting('icon_color'),
  ];
  return $element;
}