public function jCarouselFieldFormatter::settingsForm in jQuery carousel 8
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/ jCarouselFieldFormatter.php, line 119
Class
- jCarouselFieldFormatter
- Plugin annotation @FieldFormatter( id = "jquery_carousel_images", label = @Translation("jQuery Carousel"), field_types = { "image" } )
Namespace
Drupal\jquery_carousel\Plugin\Field\FieldFormatterCode
public function settingsForm(array $form, FormStateInterface $form_state) {
$elements = parent::settingsForm($form, $form_state);
$carousel_config_form = jquery_carousel_config_form();
$carousel_config_form['style_name'] = [
'#type' => 'select',
'#title' => t('Image Style'),
'#description' => t('Select the image style to be associated.'),
'#options' => image_style_options(),
'#weight' => -1,
'#default_value' => '',
];
$elements = array_merge($elements, $carousel_config_form);
$elements['selector']['#element_validate'] = [
[
get_class($this),
'jqueryCarouselSelectorValidate',
],
];
foreach (array_keys($elements) as $key) {
if (isset($elements[$key]) && is_array($elements[$key])) {
$elements[$key]['#default_value'] = $this
->getSetting($key);
}
}
return $elements;
}