protected function FormatterTrait::buildSettingsForm in Image Hover Effects 8
2 calls to FormatterTrait::buildSettingsForm()
- ImageFormatter::settingsForm in src/
Plugin/ Field/ FieldFormatter/ ImageFormatter.php - Returns a form to configure settings for the formatter.
- ResponsiveImageFormatter::settingsForm in src/
Plugin/ Field/ FieldFormatter/ ResponsiveImageFormatter.php - Returns a form to configure settings for the formatter.
File
- src/
Plugin/ Field/ FieldFormatter/ FormatterTrait.php, line 16
Class
- FormatterTrait
- Helper methods for image formatters.
Namespace
Drupal\image_hover_effects\Plugin\Field\FieldFormatterCode
protected function buildSettingsForm(&$element) {
$settings = $this
->getSettings();
// Hover effects can be only applied to links.
$states_selector = sprintf('select[name="fields[%s][settings_edit_form][settings][image_link]"]', $this->fieldDefinition
->getName());
$states['invisible'][][$states_selector]['value'] = '';
$element['hover_effect'] = [
'#type' => 'select',
'#title' => t('Image Hover Effect'),
'#options' => [
'' => t('- None -'),
] + self::getEffects(),
'#default_value' => $settings['hover_effect'],
'#states' => $states,
];
$element['hover_text'] = [
'#type' => 'textarea',
'#title' => t('Hover text'),
'#default_value' => $settings['hover_text'],
'#rows' => 3,
'#attributes' => [
'style' => 'max-width: 180px;',
],
'#states' => $states,
'#description' => t('You may use tokens to display entity data. Example: [node:title]'),
];
return $element;
}