How to get views field data in defineOptions() method of custom filter? I am  creating a custom filter for views. In *.views.inc file I am using hook_views_data_alter() to create the filter in views. Then creating a class for filter that extends NumericFilter filter class. Now, in defineOptions() method I want to feed the min and max numbers. These min and max data comes from a field in the view. Therefore, I want to know how can I get field data in that defineOptions() method.

class ItemQuantity extends NumericFilter {

  /**
   * {@inheritdoc}
   */
  public function init(ViewExecutable $view, DisplayPluginBase $display, array &amp;$options = NULL) {
    parent::init($view, $display, $options);
    $this-&gt;definition['options callback'] = array($this, 'generateOptions');
  }

  protected function defineOptions() {
    $options = parent::defineOptions();

    $options['value'] = [
      'contains' =&gt; [
        'min' =&gt; ['default' =&gt; ''],
        'max' =&gt; ['default' =&gt; ''],
        'value' =&gt; ['default' =&gt; ''],
      ],
    ];

    return $options;
  }

  public function operators() {
    $operators = parent::operators();
    $operators['overlaps'] = [
      'title' =&gt; $this-&gt;t('Overlaps by'),
      'method' =&gt; 'opOverlap',
      'short' =&gt; $this-&gt;t('&lt;&gt;'),
      'values' =&gt; 1,
    ];
    return $operators;
  }

  protected function opOverlap($field) {
    $this-&gt;query-&gt;addWhere($this-&gt;options['group'], $field, [$this-&gt;value['min'], $this-&gt;value['max']], 'IN');
  }

  /**
   * Override the query so that no filtering takes place if the user doesn't
   * select any options.
   */
  public function query() {
    if (!empty($this-&gt;value)) {
      parent::query();
    }
  }

  /**
   * Skip validation if no options have been chosen so we can use it as a
   * non-filter.
   */
  public function validate() {
    if (!empty($this-&gt;value)) {
      parent::validate();
    }
  }

}


I want to get the value of min_quantity field in the view.
You can access with:

$this-&gt;options['value']


Read more about this in Building Views Query Plugins for Drupal 8, Part 3