public function OwlFieldFormatter::settingsForm in Multipurpose Corporate Profile 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
- modules/
contrib/ owl/ src/ Plugin/ Field/ FieldFormatter/ OwlFieldFormatter.php, line 74 - Contains \Drupal\owl\Plugin\Field\FieldFormatter\OwlFieldFormatter.
Class
- OwlFieldFormatter
- Plugin implementation of the 'owl_field_formatter' formatter.
Namespace
Drupal\owl\Plugin\Field\FieldFormatterCode
public function settingsForm(array $form, FormStateInterface $form_state) {
$image_styles = image_style_options(FALSE);
$description_link = Link::fromTextAndUrl($this
->t('Configure Image Styles'), Url::fromRoute('entity.image_style.collection'));
$element['image_style'] = [
'#title' => t('Image style'),
'#type' => 'select',
'#default_value' => $this
->getSetting('image_style'),
'#empty_option' => t('None (original image)'),
'#options' => $image_styles,
'#description' => $description_link
->toRenderable() + [
'#access' => $this->currentUser
->hasPermission('administer image styles'),
],
];
$link_types = array(
'content' => t('Content'),
'file' => t('File'),
);
$element['image_link'] = array(
'#title' => t('Link image to'),
'#type' => 'select',
'#default_value' => $this
->getSetting('image_link'),
'#empty_option' => t('Nothing'),
'#options' => $link_types,
);
$element['items'] = array(
'#type' => 'number',
'#title' => $this
->t('Items'),
'#description' => $this
->t('Maximum amount of items displayed at a time with the widest browser width.'),
'#default_value' => $this
->getSetting('items'),
);
$element['itemsDesktop'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Items Desktop'),
'#description' => $this
->t('This allows you to preset the number of slides visible with a particular browser width. The format is [x,y] whereby x=browser width and y=number of slides displayed. For example [1199,4] means that if(window<=1199){ show 4 slides per page}'),
'#default_value' => $this
->getSetting('itemsDesktop'),
);
$element['itemsDesktopSmall'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Items Desktop Small'),
'#description' => $this
->t('Example: [979,3]'),
'#default_value' => $this
->getSetting('itemsDesktopSmall'),
);
$element['itemsTablet'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Items Tablet'),
'#description' => $this
->t('Example: [768,2]'),
'#default_value' => $this
->getSetting('itemsTablet'),
);
$element['itemsMobile'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Items Mobile'),
'#description' => $this
->t('Example: [479,1]'),
'#default_value' => $this
->getSetting('itemsMobile'),
);
$element['singleItem'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Single Item'),
'#default_value' => $this
->getSetting('singleItem'),
'#description' => $this
->t('Display only one item.'),
);
//itemsScaleUp
$element['itemsScaleUp'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Items ScaleUp'),
'#default_value' => $this
->getSetting('itemsScaleUp'),
'#description' => $this
->t('Option to not stretch items when it is less than the supplied items.'),
);
//slideSpeed
$element['slideSpeed'] = array(
'#type' => 'number',
'#title' => $this
->t('Slide Speed'),
'#default_value' => $this
->getSetting('slideSpeed'),
'#description' => $this
->t('Slide speed in milliseconds.'),
);
//paginationSpeed
$element['paginationSpeed'] = array(
'#type' => 'number',
'#title' => $this
->t('Pagination Speed'),
'#default_value' => $this
->getSetting('paginationSpeed'),
'#description' => $this
->t('Pagination speed in milliseconds.'),
);
//rewindSpeed
$element['rewindSpeed'] = array(
'#type' => 'number',
'#title' => $this
->t('Rewind Speed'),
'#default_value' => $this
->getSetting('rewindSpeed'),
'#description' => $this
->t('Rewind speed in milliseconds.'),
);
//autoPlay
$element['autoPlay'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('AutoPlay'),
'#default_value' => $this
->getSetting('autoPlay'),
);
//stopOnHover
$element['stopOnHover'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Stop On Hover'),
'#default_value' => $this
->getSetting('stopOnHover'),
'#description' => $this
->t('Stop autoplay on mouse hover.'),
);
//navigation
$element['navigation'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Navigation'),
'#default_value' => $this
->getSetting('navigation'),
'#description' => $this
->t('Display "next" and "prev" buttons.'),
);
//prevText
$element['prevText'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Prev Text'),
'#default_value' => $this
->getSetting('prevText'),
'#description' => $this
->t('Text for navigation prev button'),
);
//nextText
$element['nextText'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Next Text'),
'#default_value' => $this
->getSetting('nextText'),
'#description' => $this
->t('Text for navigation next button'),
);
//rewindNav
$element['rewindNav'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Rewind Nav'),
'#default_value' => $this
->getSetting('rewindNav'),
'#description' => $this
->t('Slide to first item.'),
);
//scrollPerPage
$element['scrollPerPage'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Scroll Per Page'),
'#default_value' => $this
->getSetting('scrollPerPage'),
'#description' => $this
->t('Scroll per page not per item. This affect next/prev buttons and mouse/touch dragging.'),
);
//pagination
$element['pagination'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('pagination'),
'#default_value' => $this
->getSetting('pagination'),
'#description' => $this
->t('Show pagination.'),
);
//paginationNumbers
$element['paginationNumbers'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Pagination Numbers'),
'#default_value' => $this
->getSetting('paginationNumbers'),
'#description' => $this
->t('Show numbers inside pagination buttons.'),
);
//responsive
$element['responsive'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Responsive'),
'#default_value' => $this
->getSetting('responsive'),
'#description' => $this
->t('Uncheck to use Owl Carousel on desktop-only.'),
);
//responsiveRefreshRate
$element['responsiveRefreshRate'] = array(
'#type' => 'number',
'#title' => $this
->t('Responsive Refresh Rate'),
'#default_value' => $this
->getSetting('responsiveRefreshRate'),
'#description' => $this
->t('Check window width changes every 200ms for responsive actions.'),
);
//mouseDrag
$element['mouseDrag'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Mouse Drag'),
'#default_value' => $this
->getSetting('mouseDrag'),
'#description' => $this
->t('Turn off/on mouse events.'),
);
//touchDrag
$element['touchDrag'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Touch Drag'),
'#default_value' => $this
->getSetting('touchDrag'),
'#description' => $this
->t('Turn off/on touch events.'),
);
//transitionStyle
$element['transitionStyle'] = array(
'#type' => 'select',
'#options' => array(
'fade' => $this
->t('Fade'),
'backSlide' => $this
->t('Back Slide'),
'goDown' => $this
->t('Go Down'),
'scaleUp' => $this
->t('ScaleUp'),
),
'#title' => $this
->t('Transition Style'),
'#default_value' => $this
->getSetting('transitionStyle'),
'#description' => $this
->t('Add CSS3 transition style. Works only with one item on screen.'),
);
return $element + parent::settingsForm($form, $form_state);
}