public function SlickAdmin::openingForm in Slick Carousel 8
Same name and namespace in other branches
- 8.2 src/Form/SlickAdmin.php \Drupal\slick\Form\SlickAdmin::openingForm()
- 7.3 src/Form/SlickAdmin.php \Drupal\slick\Form\SlickAdmin::openingForm()
Returns the opening form elements.
1 call to SlickAdmin::openingForm()
- SlickAdmin::buildSettingsForm in src/
Form/ SlickAdmin.php - Returns the main form elements.
File
- src/
Form/ SlickAdmin.php, line 124
Class
- SlickAdmin
- Provides resusable admin functions, or form elements.
Namespace
Drupal\slick\FormCode
public function openingForm(array &$form, $definition = []) {
$path = drupal_get_path('module', 'slick');
$readme = Url::fromUri('base:' . $path . '/README.md')
->toString();
$readme_field = Url::fromUri('base:' . $path . '/src/Plugin/Field/README.md')
->toString();
$arrows = $this
->getSkinsByGroupOptions('arrows');
$dots = $this
->getSkinsByGroupOptions('dots');
if (!isset($form['optionset'])) {
$this->blazyAdmin
->openingForm($form, $definition);
$form['optionset']['#title'] = $this
->t('Optionset main');
if ($this
->manager()
->getModuleHandler()
->moduleExists('slick_ui')) {
$route_name = 'entity.slick.collection';
$form['optionset']['#description'] = $this
->t('Manage optionsets at <a href=":url" target="_blank">the optionset admin page</a>.', [
':url' => Url::fromRoute($route_name)
->toString(),
]);
}
}
if (!empty($definition['nav']) || !empty($definition['thumbnails'])) {
$form['optionset_thumbnail'] = [
'#type' => 'select',
'#title' => $this
->t('Optionset thumbnail'),
'#options' => $this
->getOptionsetsByGroupOptions('thumbnail'),
'#description' => $this
->t('If provided, asNavFor aka thumbnail navigation applies. Leave empty to not use thumbnail navigation.'),
'#weight' => -108,
];
$form['skin_thumbnail'] = [
'#type' => 'select',
'#title' => $this
->t('Skin thumbnail'),
'#options' => $this
->getSkinsByGroupOptions('thumbnail'),
'#description' => $this
->t('Thumbnail navigation skin. See main <a href="@url" target="_blank">README</a> for details on Skins. Leave empty to not use thumbnail navigation.', [
'@url' => $readme,
]),
'#weight' => -106,
];
}
if (count($arrows) > 0) {
$form['skin_arrows'] = [
'#type' => 'select',
'#title' => $this
->t('Skin arrows'),
'#options' => $arrows ?: [],
'#enforced' => TRUE,
'#description' => $this
->t('Implement \\Drupal\\slick\\SlickSkinInterface::arrows() to add your own arrows skins, in the same format as SlickSkinInterface::skins().'),
'#weight' => -105,
];
}
if (count($dots) > 0) {
$form['skin_dots'] = [
'#type' => 'select',
'#title' => $this
->t('Skin dots'),
'#options' => $dots ?: [],
'#enforced' => TRUE,
'#description' => $this
->t('Implement \\Drupal\\slick\\SlickSkinInterface::dots() to add your own dots skins, in the same format as SlickSkinInterface::skins().'),
'#weight' => -105,
];
}
if (!empty($definition['thumb_positions'])) {
$form['thumbnail_position'] = [
'#type' => 'select',
'#title' => $this
->t('Thumbnail position'),
'#options' => [
'left' => $this
->t('Left'),
'right' => $this
->t('Right'),
'top' => $this
->t('Top'),
'over-left' => $this
->t('Overlay left'),
'over-right' => $this
->t('Overlay right'),
'over-top' => $this
->t('Overlay top'),
],
'#description' => $this
->t('By default thumbnail is positioned at bottom. Hence to change the position of thumbnail. Only reasonable with 1 visible main stage at a time. Except any TOP, the rest requires Vertical option enabled for Optionset thumbnail, and a custom CSS height to selector <strong>.slick--thumbnail</strong> to avoid overflowing tall thumbnails, or adjust <strong>slidesToShow</strong> to fit the height. Further theming is required as usual. Overlay is absolutely positioned over the stage rather than sharing the space. See skin <strong>X VTabs</strong> for vertical thumbnail sample.'),
'#states' => [
'visible' => [
'select[name*="[optionset_thumbnail]"]' => [
'!value' => '',
],
],
],
'#weight' => -99,
];
}
if (!empty($definition['thumb_captions'])) {
$form['thumbnail_caption'] = [
'#type' => 'select',
'#title' => $this
->t('Thumbnail caption'),
'#options' => $definition['thumb_captions'],
'#description' => $this
->t('Thumbnail caption maybe just title/ plain text. If Thumbnail image style is not provided, the thumbnail pagers will be just text like regular tabs.'),
'#states' => [
'visible' => [
'select[name*="[optionset_thumbnail]"]' => [
'!value' => '',
],
],
],
'#weight' => 2,
];
}
if (isset($form['skin'])) {
$form['skin']['#title'] = $this
->t('Skin main');
$form['skin']['#description'] = $this
->t('Skins allow various layouts with just CSS. Some options below depend on a skin. However a combination of skins and options may lead to unpredictable layouts, get yourself dirty. E.g.: Skin Split requires any split layout option. Failing to choose the expected layout makes it useless. See <a href=":url" target="_blank">SKINS section at README.md</a> for details on Skins. Leave empty to DIY. Or use hook_slick_skins_info() and implement \\Drupal\\slick\\SlickSkinInterface to register ones.', [
':url' => $readme,
]);
}
if (isset($form['layout'])) {
$form['layout']['#description'] = $this
->t('Requires a skin. The builtin layouts affects the entire slides uniformly. Split half requires any skin Split. See <a href="@url" target="_blank">README</a> under "Slide layout" for more info. Leave empty to DIY.', [
'@url' => $readme_field,
]);
}
$weight = -99;
foreach (Element::children($form) as $key) {
if (!isset($form[$key]['#weight'])) {
$form[$key]['#weight'] = ++$weight;
}
}
}