I am trying to do something that should be easy in Views but I can't seem to be able to make it work.
I need to create a filter on top of the existing NumericFilter
(Drupal\views\Plugin\views\filter\NumericFilter
), but with a minimalistic approach like the following it is simply not working.
<?php
// @file src/Plugin/views/filter/FoobarProjectSizeRangeSelectionFilter.php
namespace Drupal\foobar_extra\Plugin\views\filter;
use Drupal\views\Plugin\views\filter\NumericFilter;
/**
* Class DateYearFilter
* @ingroup views_filter_handlers
* @ViewsFilter("project_size_range_select")
*/
class FoobarProjectSizeRangeSelectionFilter extends NumericFilter {
}
The way I use is is pretty straight forward:
<?php
// @file foobar.views.php
/**
* Implements hook_views_data_alter().
*/
function foobar_views_data_alter(array &$data) {
// clone an existing field
$data['node__field_a']['field_a_value_range'] = $data['node__field_a']['field_a_value'];
// change name and filter ID
$data['node__field_a']['field_a_value_range']['title'] = t("Foobar");
$data['node__field_a']['field_a_value_range']['filter']['id'] = 'project_size_range_select';
return $data;
}
Whenever I try to save a view using this filter plugin i get the following error:
InvalidArgumentException: The configuration property display.default.display_options.filters.field_a_value_range.value.min doesn't exist. in Drupal\Core\Config\Schema\ArrayElement->get() (line 74 of ROOT/web/core/lib/Drupal/Core/Config/Schema/ArrayElement.php).
Right now I have "worked around it" implementing some custom and terrible hacks, but i'm pretty sure this is so simple that it should just work.