public function FieldCollectionSlideshow::settingsForm in Field Slideshow 8
Same name and namespace in other branches
- 8.2 src/Plugin/Field/FieldFormatter/FieldCollectionSlideshow.php \Drupal\field_slideshow\Plugin\Field\FieldFormatter\FieldCollectionSlideshow::settingsForm()
File
- src/
Plugin/ Field/ FieldFormatter/ FieldCollectionSlideshow.php, line 70 - Contains \Drupal\field_slideshow\Plugin\Field\FieldFormatter\Slideshow.
Class
- FieldCollectionSlideshow
- Plugin implementation of the 'slideshow' formatter.
Namespace
Drupal\field_slideshow\Plugin\Field\FieldFormatterCode
public function settingsForm(array $form, FormStateInterface $form_state) {
$image_styles = image_style_options(FALSE);
// get image_style and image_link form elements from parent method.
$element = parent::settingsForm($form, $form_state);
$entity_type_id = 'node';
$bundle = $form['#bundle'];
$definitions = \Drupal::service('entity_field.manager')
->getFieldDefinitions('node', $bundle);
foreach ($definitions as $field_name => $field_definition) {
if ($field_definition
->getType() == 'field_collection') {
$fname = $field_definition
->getName();
}
}
$field_options = $this
->field_slideshow_get_fields('image', $bundle, $fname);
$element['image_field'] = array(
'#title' => t('Image Field'),
'#type' => 'select',
'#default_value' => $this
->getSetting('image_field'),
'#empty_option' => t('None'),
'#options' => $field_options,
'#required' => TRUE,
);
$element['image_style'] = array(
'#title' => t('Image style'),
'#type' => 'select',
'#default_value' => $this
->getSetting('image_style'),
'#empty_option' => t('None (original image)'),
'#options' => $image_styles,
);
$link_types = array(
'content' => t('Content'),
'file' => t('File'),
);
$element['image_link'] = array(
'#title' => t('Links image to'),
'#type' => 'select',
'#default_value' => $this
->getSetting('image_link'),
'#empty_option' => t('Nothing'),
'#options' => $link_types,
'#states' => array(
'invisible' => array(
':input[name$="[settings_edit_form][settings][image_field]"]' => array(
'value' => '',
),
),
),
);
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',
),
),
),
);
}
$captions = array(
'title' => t('Title text'),
'alt' => t('Alt text'),
);
$caption_add = $this
->field_slideshow_get_fields('string_long', $bundle, $fname);
$captions = array_merge($captions, $caption_add);
$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;
}