- Issue created by @solideogloria
- @solideogloria opened merge request.
- Status changed to Needs review
almost 2 years ago 9:58pm 24 May 2023
I have a webform with a checkbox element. When I create a view, the element can be added as a field or a filter, but it cannot be added to sort by it.
WebformElementViewsAbstract::getViewsData
runs this:
foreach ($this->getElementViewsData($element_plugin, $element) as $k => $v) {
$v += [
'webform_id' => $webform->id(),
'webform_submission_field' => $element['#webform_key'],
];
$data[$table_alias]['webform_submission_value'][$k] = $v;
}
Since class WebformCheckboxViews extends WebformElementViewsAbstract
, WebformCheckboxViews::getElementViewsData
adds the WebformElementViewsAbstract
's $views_data
, which is just the field plugin, and it then adds the checkbox filter plugin. However, no sort plugin is ever added.
Change which class is extended.
class WebformCheckboxViews extends WebformDefaultViews {
WebformDefaultViews
will add the default sort plugin, along with a filter plugin that is not desired, however WebformCheckboxViews
immediately replaces the default filter plugin with its own, so the desired result is achieved.
In addition, it also enables using checkbox values as view arguments, because that couldn't be done before, either.
Needs review
5.0
Code