0

I need your help.

I try to make a custom views filter with a entity reference. I have some problem. I have this message, when I declared :

The handler of this element is defective or missing. The following details are available:

Activating the appropriate module can solve this problem. Otherwise, check if there is an available module update.

I get this message in "Entry report" section :

Message Notice : Undefined variable: items dans Drupal\views\Plugin\views\filter\Broken->buildOptionsForm()

Message Notice : Undefined index: field dans Drupal\views\Plugin\ViewsHandlerManager->getHandler()

Hook implementation:

function module_views_data_alter(array &$data)
{

  $data['distri_prod_entity_field_data']['distri_id']['filter'] = [

          'id' => 'module_distri_prod_distri_filter'

      ];
}

Filter Class:

<?php


namespace Drupal\module\Plugin\view\filter;


use Drupal\module\Helper\DistributeurHelper;
use Drupal\views\Annotation\ViewsFilter;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\filter\ManyToOne;
use Drupal\views\ViewExecutable;

/**
 * Filters by given list of node title options.
 *
 * @ingroup views_filter_handlers
 *
 * @ViewsFilter("module_distri_prod_distri_filter")
 */

class DistriProdDistriFilter extends ManyToOne
{

  public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
    parent::init($view, $display, $options);
    $this->valueTitle = t('Allowed related content titles');
    $this->definition['options callback'] = array($this, 'generateOptions');
  }

  /**
   * Helper function that generates the options.
   * @return array
   */
  public function generateOptions() {
    return DistributeurHelper::OptionList();
  }

}

Can you help me?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.