public function FieldSlideshow::settingsForm in Field Slideshow 8
Same name and namespace in other branches
- 8.3 src/Plugin/Field/FieldFormatter/FieldSlideshow.php \Drupal\field_slideshow\Plugin\Field\FieldFormatter\FieldSlideshow::settingsForm()
- 8.2 src/Plugin/Field/FieldFormatter/FieldSlideshow.php \Drupal\field_slideshow\Plugin\Field\FieldFormatter\FieldSlideshow::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 ImageFormatter::settingsForm
File
- src/
Plugin/ Field/ FieldFormatter/ FieldSlideshow.php, line 57 - Contains \Drupal\field_slideshow\Plugin\Field\FieldFormatter\Slideshow.
Class
- FieldSlideshow
- Plugin implementation of the 'slideshow' formatter.
Namespace
Drupal\field_slideshow\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 = array(
'content' => t('Content'),
'file' => t('File'),
);
$captions = array(
'title' => t('Title text'),
'alt' => t('Alt text'),
);
if (\Drupal::moduleHandler()
->moduleExists('colorbox')) {
$element['image_link']['#options']['colorbox'] = 'Colorbox';
$element['slideshow_colorbox_image_style'] = array(
'#title' => t('Colorbox image style'),
'#type' => 'select',
'#default_value' => $this
->getSetting('slideshow_colorbox_image_style'),
'#empty_option' => t('None (original image)'),
'#options' => image_style_options(FALSE),
'#states' => array(
'visible' => array(
':input[name$="[settings_edit_form][settings][image_link]"]' => array(
'value' => 'colorbox',
),
),
),
);
$colorbox_slideshow = array(
'automatic' => t('Automatic'),
'manual' => t('Manual'),
);
$element['slideshow_colorbox_slideshow'] = array(
'#title' => t('Colorbox slideshow'),
'#type' => 'select',
'#default_value' => $this
->getSetting('slideshow_colorbox_slideshow'),
'#empty_option' => t('No slideshow'),
'#options' => $colorbox_slideshow,
'#states' => array(
'visible' => array(
':input[name$="[settings_edit_form][settings][image_link]"]' => array(
'value' => 'colorbox',
),
),
),
);
$element['slideshow_colorbox_slideshow_speed'] = array(
'#title' => t('Colorbox slideshow speed'),
'#type' => 'textfield',
'#size' => 5,
'#default_value' => $this
->getSetting('slideshow_colorbox_slideshow_speed'),
'#description' => t('Time between transitions (ms).'),
'#states' => array(
'invisible' => array(
':input[name$="[settings_edit_form][settings][slideshow_colorbox_slideshow]"]' => array(
'value' => '',
),
),
),
);
$colorbox_transitions = array(
'none' => t('None'),
'elastic' => t('Elastic'),
'fade' => t('Fade'),
);
$element['slideshow_colorbox_transition'] = array(
'#title' => t('Colorbox transition'),
'#type' => 'select',
'#default_value' => $this
->getSetting('slideshow_colorbox_transition'),
'#options' => $colorbox_transitions,
'#states' => array(
'visible' => array(
':input[name$="[settings_edit_form][settings][image_link]"]' => array(
'value' => 'colorbox',
),
),
),
);
$element['slideshow_colorbox_speed'] = array(
'#title' => t('Colorbox transition speed'),
'#type' => 'textfield',
'#size' => 5,
'#default_value' => $this
->getSetting('slideshow_colorbox_speed'),
'#description' => t('Duration of transition (ms).'),
'#states' => array(
'visible' => array(
':input[name$="[settings_edit_form][settings][image_link]"]' => array(
'value' => 'colorbox',
),
),
),
);
}
$element['slideshow_caption'] = array(
'#title' => t('Caption'),
'#type' => 'select',
'#default_value' => $this
->getSetting('slideshow_caption'),
'#empty_option' => t('Nothing'),
'#options' => $captions,
);
$element['slideshow_caption_link'] = array(
'#title' => t('Caption link'),
'#type' => 'select',
'#default_value' => $this
->getSetting('slideshow_caption_link'),
'#empty_option' => t('Nothing'),
'#options' => $link_types,
'#states' => array(
'invisible' => array(
':input[name$="[settings_edit_form][settings][slideshow_caption]"]' => array(
'value' => '',
),
),
),
);
$element['slideshow_fx'] = array(
'#title' => t('Transition effect'),
'#type' => 'select',
'#default_value' => $this
->getSetting('slideshow_fx'),
'#options' => array(
'blindX' => t('blindX'),
'blindY' => t('blindY'),
'blindZ' => t('blindZ'),
'cover' => t('cover'),
'curtainX' => t('curtainX'),
'curtainY' => t('curtainY'),
'fade' => t('fade'),
'fadeZoom' => t('fadeZoom'),
'growX' => t('growX'),
'growY' => t('growY'),
'scrollUp' => t('scrollUp'),
'scrollDown' => t('scrollDown'),
'scrollLeft' => t('scrollLeft'),
'scrollRight' => t('scrollRight'),
'scrollHorz' => t('scrollHorz'),
'scrollVert' => t('scrollVert'),
'shuffle' => t('shuffle'),
'slideX' => t('slideX'),
'slideY' => t('slideY'),
'toss' => t('toss'),
'turnUp' => t('turnUp'),
'turnDown' => t('turnDown'),
'turnLeft' => t('turnLeft'),
'turnRight' => t('turnRight'),
'uncover' => t('uncover'),
'wipe' => t('wipe'),
'zoom' => t('zoom'),
),
);
$element['slideshow_speed'] = array(
'#title' => t('Transition speed'),
'#type' => 'textfield',
'#size' => 5,
'#default_value' => $this
->getSetting('slideshow_speed'),
'#description' => t('Duration of transition (ms).'),
'#required' => TRUE,
);
$element['slideshow_timeout'] = array(
'#title' => t('Timeout'),
'#type' => 'textfield',
'#size' => 5,
'#default_value' => $this
->getSetting('slideshow_timeout'),
'#description' => t('Time between transitions (ms). Enter 0 to disable automatic transitions (then, enable pager and/or controls).'),
'#required' => TRUE,
);
$element['slideshow_order'] = array(
'#title' => t('Order'),
'#type' => 'select',
'#default_value' => $this
->getSetting('slideshow_order'),
'#empty_option' => t('Normal'),
'#options' => array(
'reverse' => t('Reverse'),
'random' => t('Random'),
),
);
$element['slideshow_controls'] = array(
'#title' => t('Create prev/next controls'),
'#type' => 'checkbox',
'#default_value' => $this
->getSetting('slideshow_controls'),
);
$element['slideshow_controls_pause'] = array(
'#title' => t('Create play/pause button'),
'#type' => 'checkbox',
'#default_value' => $this
->getSetting('slideshow_controls_pause'),
'#states' => array(
'visible' => array(
':input[name$="[settings_edit_form][settings][slideshow_controls]"]' => array(
'checked' => TRUE,
),
),
),
);
$element['slideshow_controls_position'] = array(
'#title' => t('Prev/next controls position'),
'#type' => 'select',
'#options' => array(
'before' => 'Before',
'after' => 'After',
),
'#default_value' => $this
->getSetting('slideshow_controls_position'),
'#states' => array(
'visible' => array(
':input[name$="[settings_edit_form][settings][slideshow_controls]"]' => array(
'checked' => TRUE,
),
),
),
);
$element['slideshow_pause'] = array(
'#title' => t('Pause on hover'),
'#type' => 'checkbox',
'#default_value' => $this
->getSetting('slideshow_pause'),
);
$element['slideshow_start_on_hover'] = array(
'#title' => t('Activate on hover'),
'#type' => 'checkbox',
'#default_value' => $this
->getSetting('slideshow_start_on_hover'),
);
$element['slideshow_pager'] = array(
'#title' => t('Pager'),
'#type' => 'select',
'#options' => array(
'number' => 'Slide number',
'image' => 'Image',
),
'#empty_option' => t('None'),
'#default_value' => $this
->getSetting('slideshow_pager'),
);
$element['slideshow_pager_position'] = array(
'#title' => t('Pager position'),
'#type' => 'select',
'#options' => array(
'before' => 'Before',
'after' => 'After',
),
'#default_value' => $this
->getSetting('slideshow_pager_position'),
'#states' => array(
'invisible' => array(
':input[name$="[settings_edit_form][settings][slideshow_pager]"]' => array(
'value' => '',
),
),
),
);
$element['slideshow_pager_image_style'] = array(
'#title' => t('Pager image style'),
'#type' => 'select',
'#default_value' => $this
->getSetting('slideshow_pager_image_style'),
'#empty_option' => t('None (original image)'),
'#options' => image_style_options(FALSE),
'#states' => array(
'visible' => array(
':input[name$="[settings_edit_form][settings][slideshow_pager]"]' => array(
'value' => 'image',
),
),
),
);
return $element;
}