public function OrbitFormatter::settingsForm in ZURB Orbit 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 ImageFormatter::settingsForm
File
- src/
Plugin/ Field/ FieldFormatter/ OrbitFormatter.php, line 55
Class
- OrbitFormatter
- Plugin implementation of the 'Orbit' formatter.
Namespace
Drupal\field_orbit\Plugin\Field\FieldFormatterCode
public function settingsForm(array $form, FormStateInterface $form_state) {
// Get image_style and image_link form elements from parent method.
$element = parent::settingsForm($form, $form_state);
$link_types = [
'content' => $this
->t('Content'),
'file' => $this
->t('File'),
];
$captions = [
'title' => $this
->t('Title text'),
'alt' => $this
->t('Alt text'),
];
$element['caption'] = [
'#title' => $this
->t('Caption'),
'#type' => 'select',
'#default_value' => $this
->getSetting('caption'),
'#empty_option' => $this
->t('Nothing'),
'#options' => $captions,
];
$element['caption_link'] = [
'#title' => $this
->t('Link caption to'),
'#type' => 'select',
'#default_value' => $this
->getSetting('caption_link'),
'#empty_option' => $this
->t('Nothing'),
'#options' => $link_types,
'#states' => [
'invisible' => [
':input[name$="[settings_edit_form][settings][caption]"]' => [
'value' => '',
],
],
],
];
$element['animInFromRight'] = [
'#type' => 'select',
'#title' => $this
->t('animInFromRight'),
'#default_value' => $this
->getSetting('animInFromRight'),
'#options' => $this
->getAnimationInOptions(),
];
$element['animOutToRight'] = [
'#type' => 'select',
'#title' => $this
->t('animOutToRight'),
'#default_value' => $this
->getSetting('animOutToRight'),
'#options' => $this
->getAnimationOutOptions(),
];
$element['animInFromLeft'] = [
'#type' => 'select',
'#title' => $this
->t('animInFromLeft'),
'#default_value' => $this
->getSetting('animInFromLeft'),
'#options' => $this
->getAnimationInOptions(),
];
$element['animOutToLeft'] = [
'#type' => 'select',
'#title' => $this
->t('animOutToLeft'),
'#default_value' => $this
->getSetting('animOutToLeft'),
'#options' => $this
->getAnimationOutOptions(),
];
$element['autoPlay'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Autoplay'),
'#default_value' => $this
->getSetting('autoPlay'),
'#description' => $this
->t('Allows Orbit to automatically animate on page load.'),
];
$element['timerDelay'] = [
'#type' => 'textfield',
'#title' => $this
->t('Timer speed'),
'#element_validate' => [
'element_validate_integer_positive',
],
'#default_value' => $this
->getSetting('timerDelay'),
'#description' => $this
->t('Amount of time, in ms, between slide transitions'),
];
$element['infiniteWrap'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Infinite Wrap'),
'#default_value' => $this
->getSetting('infiniteWrap'),
'#description' => $this
->t('Allows Orbit to infinitely loop through the slides.'),
];
$element['swipe'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Swipe'),
'#default_value' => $this
->getSetting('swipe'),
'#description' => $this
->t('Allows the Orbit slides to bind to swipe events for mobile.'),
];
$element['pauseOnHover'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Pause on hover'),
'#default_value' => $this
->getSetting('pauseOnHover'),
'#description' => $this
->t('Pause slideshow when you hover on the slide.'),
];
$element['accessible'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Keyboard events'),
'#default_value' => $this
->getSetting('accessible'),
'#description' => $this
->t('Allows Orbit to bind keyboard events to the slider.'),
];
$element['bullets'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Bullets'),
'#default_value' => $this
->getSetting('bullets'),
'#description' => $this
->t('Show bullets.'),
];
$element['navButtons'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Nav buttons'),
'#default_value' => $this
->getSetting('navButtons'),
'#description' => $this
->t('Show navigations buttons.'),
];
$element['containerClass'] = [
'#type' => 'textfield',
'#title' => $this
->t('Container Class'),
'#default_value' => $this
->getSetting('containerClass'),
'#description' => $this
->t('Class applied to the container of Orbit'),
];
$element['slideClass'] = [
'#type' => 'textfield',
'#title' => $this
->t('slide class'),
'#default_value' => $this
->getSetting('slideClass'),
'#description' => $this
->t('Class applied to individual slides.'),
];
$element['boxOfBullets'] = [
'#type' => 'textfield',
'#title' => $this
->t('Bullets class'),
'#default_value' => $this
->getSetting('boxOfBullets'),
'#description' => $this
->t('Class applied to the bullet container.'),
];
$element['nextClass'] = [
'#type' => 'textfield',
'#title' => $this
->t('Next class'),
'#default_value' => $this
->getSetting('nextClass'),
'#description' => $this
->t('Class applied to the `next` navigation buton.'),
];
$element['prevClass'] = [
'#type' => 'textfield',
'#title' => $this
->t('Prev class'),
'#default_value' => $this
->getSetting('prevClass'),
'#description' => $this
->t('Class applied to the `previous` navigation button.'),
];
return $element;
}