public function StarRatingFormatter::settingsForm in Star Rating 8.3
Same name and namespace in other branches
- 8.4 src/Plugin/Field/FieldFormatter/StarRatingFormatter.php \Drupal\starrating\Plugin\Field\FieldFormatter\StarRatingFormatter::settingsForm()
- 8 src/Plugin/Field/FieldFormatter/StarRatingFormatter.php \Drupal\starrating\Plugin\Field\FieldFormatter\StarRatingFormatter::settingsForm()
- 8.2 src/Plugin/Field/FieldFormatter/StarRatingFormatter.php \Drupal\starrating\Plugin\Field\FieldFormatter\StarRatingFormatter::settingsForm()
Returns a form to configure settings for the formatter.
Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase to allow administrators to configure the formatter. 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 elements for the formatter settings.
Overrides FormatterBase::settingsForm
File
- src/
Plugin/ Field/ FieldFormatter/ StarRatingFormatter.php, line 58
Class
- StarRatingFormatter
- Plugin implementation of the 'Starrating' formatter.
Namespace
Drupal\starrating\Plugin\Field\FieldFormatterCode
public function settingsForm(array $form, FormStateInterface $form_state) {
global $base_url;
$element = array();
$element['fill_blank'] = array(
'#type' => 'checkbox',
'#title' => t('Fill with blank icons'),
'#default_value' => $this
->getSetting('fill_blank'),
);
$element['icon_type'] = array(
'#type' => 'select',
'#title' => t('Icon type'),
'#options' => array(
'star' => t('Star'),
'starline' => t('Star (outline)'),
'check' => t('Check'),
'heart' => t('Heart'),
'dollar' => t('Dollar'),
'smiley' => t('Smiley'),
'food' => t('Food'),
'coffee' => t('Coffee'),
'movie' => t('Movie'),
'music' => t('Music'),
'human' => t('Human'),
'thumbsup' => t('Thumbs Up'),
'car' => t('Car'),
'airplane' => t('Airplane'),
'fire' => t('Fire'),
'drupalicon' => t('Drupalicon'),
'custom' => t('Custom'),
),
'#default_value' => $this
->getSetting('icon_type'),
'#prefix' => '<img src="' . $base_url . '/' . drupal_get_path('module', 'starrating') . '/css/sample.png" />',
);
$element['icon_color'] = array(
'#type' => 'select',
'#title' => 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;
}