function InputRequired::preRender
Same name in other branches
- 9 core/modules/views/src/Plugin/views/exposed_form/InputRequired.php \Drupal\views\Plugin\views\exposed_form\InputRequired::preRender()
- 10 core/modules/views/src/Plugin/views/exposed_form/InputRequired.php \Drupal\views\Plugin\views\exposed_form\InputRequired::preRender()
- 11.x core/modules/views/src/Plugin/views/exposed_form/InputRequired.php \Drupal\views\Plugin\views\exposed_form\InputRequired::preRender()
Overrides ExposedFormPluginBase::preRender
File
-
core/
modules/ views/ src/ Plugin/ views/ exposed_form/ InputRequired.php, line 70
Class
- InputRequired
- Exposed form plugin that provides an exposed form with required input.
Namespace
Drupal\views\Plugin\views\exposed_formCode
public function preRender($values) {
// Display the "text on demand" if needed. This is a site builder-defined
// text to display instead of results until the user selects and applies
// an exposed filter.
if (!$this->exposedFilterApplied()) {
$options = [
'id' => 'area',
'table' => 'views',
'field' => 'area',
'label' => '',
'relationship' => 'none',
'group_type' => 'group',
// We need to set the "Display even if view has no result" option to
// TRUE as the input required exposed form plugin will always force an
// empty result if no exposed filters are applied.
'empty' => TRUE,
'content' => [
// @see \Drupal\views\Plugin\views\area\Text::render()
'value' => $this->options['text_input_required'],
'format' => $this->options['text_input_required_format'],
],
];
$handler = Views::handlerManager('area')->getHandler($options);
$handler->init($this->view, $this->displayHandler, $options);
$this->displayHandler->handlers['empty'] = [
'area' => $handler,
];
// Override the existing empty result message (if applicable).
$this->displayHandler
->setOption('empty', [
'text' => $options,
]);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.