Gridstack.php in Sooperthemes GridStack 8
File
src/Plugin/views/row/Gridstack.php
View source
<?php
namespace Drupal\sooperthemes_gridstack\Plugin\views\row;
use Drupal\Core\Form\FormStateInterface;
use Drupal\views\Plugin\views\row\RowPluginBase;
class Gridstack extends RowPluginBase {
protected $usesFields = TRUE;
protected function defineOptions() {
$options = parent::defineOptions();
$options['image'] = [
'default' => '',
];
$options['title'] = [
'default' => '',
];
$options['category'] = [
'default' => '',
];
return $options;
}
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$fields = [];
foreach ($this->displayHandler
->getHandlers('field') as $field => $handler) {
$fields[$field] = $field;
}
$form['image'] = [
'#type' => 'select',
'#required' => TRUE,
'#title' => t('Image'),
'#options' => [
'' => t('- None -'),
] + $fields,
'#default_value' => $this->options['image'],
];
$form['title'] = [
'#type' => 'select',
'#title' => t('Title'),
'#options' => [
'' => t('- None -'),
] + $fields,
'#default_value' => $this->options['title'],
];
$form['category'] = [
'#type' => 'select',
'#title' => t('Category'),
'#options' => [
'' => t('- None -'),
] + $fields,
'#default_value' => $this->options['category'],
];
}
}