public function Gridstack::buildOptionsForm in Sooperthemes GridStack 8
Same name in this branch
- 8 src/Plugin/views/style/Gridstack.php \Drupal\sooperthemes_gridstack\Plugin\views\style\Gridstack::buildOptionsForm()
- 8 src/Plugin/views/row/Gridstack.php \Drupal\sooperthemes_gridstack\Plugin\views\row\Gridstack::buildOptionsForm()
Provide a form to edit options for this plugin.
Overrides StylePluginBase::buildOptionsForm
File
- src/
Plugin/ views/ style/ Gridstack.php, line 46
Class
- Gridstack
- Style plugin to render each item in an ordered or unordered list.
Namespace
Drupal\sooperthemes_gridstack\Plugin\views\styleCode
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$form['#prefix'] = '<div id="sooperthemes-gridstack-grid-stack-admin">';
$form['#sufix'] = '</div>';
$form['gridstack_layout'] = [
'#type' => 'select',
'#title' => t('Layout Presets'),
'#options' => [
'custom' => t('Custom'),
'example_1' => t('5 Items'),
'example_2' => t('4 Items'),
'example_3' => t('7 Items'),
],
'#default_value' => $this->options['gridstack_layout'],
];
$form['gridstack_items'] = [
'#type' => 'number',
'#title' => t('Number of items'),
'#default_value' => $this->options['gridstack_items'],
'#min' => 1,
'#max' => 100,
];
$form['gridstack_overlay'] = [
'#type' => 'select',
'#title' => t('Image overlay effect'),
'#options' => [
'' => t('None'),
'dark' => t('Dark'),
'light' => t('Light'),
'rainbow' => t('Rainbow'),
],
'#default_value' => $this->options['gridstack_overlay'],
];
$form['more'] = [
'#type' => 'details',
'#title' => t('More settings'),
];
$form['more']['gridstack_zoom'] = [
'#type' => 'checkbox',
'#title' => t('Image zoom effect on hover'),
'#default_value' => $this->options['gridstack_zoom'],
];
$form['more']['gridstack_gap'] = [
'#type' => 'number',
'#title' => t('Gap size'),
'#default_value' => $this->options['gridstack_gap'],
'#min' => 0,
];
$form['more']['gridstack_items_mobile'] = [
'#type' => 'number',
'#title' => t('Number of items in mobile view'),
'#default_value' => $this->options['gridstack_items_mobile'],
'#min' => 1,
'#max' => 100,
];
$form['gridstack_layout_template'] = [
'#prefix' => '<h3>' . t('Modify layout (drag and drop)') . '</h3>',
'#markup' => '<div class="grid-stack"></div>',
];
$form['more']['gridstack_layout_data'] = [
'#type' => 'textarea',
'#title' => t('Custom layout data'),
'#default_value' => $this->options['gridstack_layout_data'],
'#description' => t('Define `media queries` for columns/rows layout in JSON format. As example you can see predefined layouts.'),
];
$form['#attached']['drupalSettings']['sooperthemesGridStack']['layoutDataAdmin'] = $form['more']['gridstack_layout_data']['#default_value'];
$form['#attached']['library'][] = 'sooperthemes_gridstack/admin';
}