function StylePluginBase::buildOptionsForm
Same name in other branches
- 9 core/modules/views/src/Plugin/views/style/StylePluginBase.php \Drupal\views\Plugin\views\style\StylePluginBase::buildOptionsForm()
- 8.9.x core/modules/views/src/Plugin/views/style/StylePluginBase.php \Drupal\views\Plugin\views\style\StylePluginBase::buildOptionsForm()
- 10 core/modules/views/src/Plugin/views/style/StylePluginBase.php \Drupal\views\Plugin\views\style\StylePluginBase::buildOptionsForm()
Overrides PluginBase::buildOptionsForm
9 calls to StylePluginBase::buildOptionsForm()
- EntityReference::buildOptionsForm in core/
modules/ views/ src/ Plugin/ views/ style/ EntityReference.php - Provide a form to edit options for this plugin.
- Grid::buildOptionsForm in core/
modules/ views/ src/ Plugin/ views/ style/ Grid.php - Provide a form to edit options for this plugin.
- GridResponsive::buildOptionsForm in core/
modules/ views/ src/ Plugin/ views/ style/ GridResponsive.php - Provide a form to edit options for this plugin.
- HtmlList::buildOptionsForm in core/
modules/ views/ src/ Plugin/ views/ style/ HtmlList.php - Render the given style.
- Mapping::buildOptionsForm in core/
modules/ views/ src/ Plugin/ views/ style/ Mapping.php - Provide a form to edit options for this plugin.
10 methods override StylePluginBase::buildOptionsForm()
- DefaultSummary::buildOptionsForm in core/
modules/ views/ src/ Plugin/ views/ style/ DefaultSummary.php - Provide a form to edit options for this plugin.
- EntityReference::buildOptionsForm in core/
modules/ views/ src/ Plugin/ views/ style/ EntityReference.php - Provide a form to edit options for this plugin.
- Grid::buildOptionsForm in core/
modules/ views/ src/ Plugin/ views/ style/ Grid.php - Provide a form to edit options for this plugin.
- GridResponsive::buildOptionsForm in core/
modules/ views/ src/ Plugin/ views/ style/ GridResponsive.php - Provide a form to edit options for this plugin.
- HtmlList::buildOptionsForm in core/
modules/ views/ src/ Plugin/ views/ style/ HtmlList.php - Render the given style.
File
-
core/
modules/ views/ src/ Plugin/ views/ style/ StylePluginBase.php, line 284
Class
- StylePluginBase
- Base class for views style plugins.
Namespace
Drupal\views\Plugin\views\styleCode
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
// Only fields-based views can handle grouping. Style plugins can also exclude
// themselves from being groupable by setting their "usesGrouping" property
// to FALSE.
// @todo Document "usesGrouping" in docs.php when docs.php is written.
if ($this->usesFields() && $this->usesGrouping()) {
$options = [
'' => $this->t('- None -'),
];
$field_labels = $this->displayHandler
->getFieldLabels(TRUE);
$options += $field_labels;
// If there are no fields, we can't group on them.
if (count($options) > 1) {
// This is for backward compatibility, when there was just a single
// select form.
if (is_string($this->options['grouping'])) {
$grouping = $this->options['grouping'];
$this->options['grouping'] = [];
$this->options['grouping'][0]['field'] = $grouping;
}
if (isset($this->options['group_rendered']) && is_string($this->options['group_rendered'])) {
$this->options['grouping'][0]['rendered'] = $this->options['group_rendered'];
unset($this->options['group_rendered']);
}
$c = count($this->options['grouping']);
// Add a form for every grouping, plus one.
for ($i = 0; $i <= $c; $i++) {
$grouping = !empty($this->options['grouping'][$i]) ? $this->options['grouping'][$i] : [];
$grouping += [
'field' => '',
'rendered' => TRUE,
'rendered_strip' => FALSE,
];
$form['grouping'][$i]['field'] = [
'#type' => 'select',
'#title' => $this->t('Grouping field Nr.@number', [
'@number' => $i + 1,
]),
'#options' => $options,
'#default_value' => $grouping['field'],
'#description' => $this->t('You may optionally specify a field by which to group the records. Leave blank to not group.'),
];
$form['grouping'][$i]['rendered'] = [
'#type' => 'checkbox',
'#title' => $this->t('Use rendered output to group rows'),
'#default_value' => $grouping['rendered'],
'#description' => $this->t('If enabled the rendered output of the grouping field is used to group the rows.'),
'#states' => [
'invisible' => [
':input[name="style_options[grouping][' . $i . '][field]"]' => [
'value' => '',
],
],
],
];
$form['grouping'][$i]['rendered_strip'] = [
'#type' => 'checkbox',
'#title' => $this->t('Remove tags from rendered output'),
'#default_value' => $grouping['rendered_strip'],
'#states' => [
'invisible' => [
':input[name="style_options[grouping][' . $i . '][field]"]' => [
'value' => '',
],
],
],
];
}
}
}
if ($this->usesRowClass()) {
$form['row_class'] = [
'#title' => $this->t('Row class'),
'#description' => $this->t('The class to provide on each row.'),
'#type' => 'textfield',
'#default_value' => $this->options['row_class'],
];
if ($this->usesFields()) {
$form['row_class']['#description'] .= ' ' . $this->t('You may use field tokens as per the "Replacement patterns" used in "Rewrite the output of this field" for all fields.');
}
$form['default_row_class'] = [
'#title' => $this->t('Add views row classes'),
'#description' => $this->t('Add the default row classes like @classes to the output. You can use this to quickly reduce the amount of markup the view provides by default, at the cost of making it more difficult to apply CSS.', [
'@classes' => 'views-row',
]),
'#type' => 'checkbox',
'#default_value' => $this->options['default_row_class'],
];
}
if (!$this->usesFields() || !empty($this->options['uses_fields'])) {
$form['uses_fields'] = [
'#type' => 'checkbox',
'#title' => $this->t('Force using fields'),
'#description' => $this->t('If neither the row nor the style plugin supports fields, this field allows to enable them, so you can for example use groupby.'),
'#default_value' => $this->options['uses_fields'],
];
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.