ViewsReferenceWidget.php in Views Reference Field 8.2
File
src/Plugin/Field/FieldWidget/ViewsReferenceWidget.php
View source
<?php
namespace Drupal\viewsreference\Plugin\Field\FieldWidget;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\Validator\ConstraintViolationInterface;
use Drupal\Core\Field\Plugin\Field\FieldWidget\EntityReferenceAutocompleteWidget;
class ViewsReferenceWidget extends EntityReferenceAutocompleteWidget {
use ViewsReferenceTrait;
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
$element = parent::formElement($items, $delta, $element, $form, $form_state);
$element = $this
->fieldElement($items, $delta, $element, $form, $form_state);
return $element;
}
public function errorElement(array $element, ConstraintViolationInterface $error, array $form, FormStateInterface $form_state) {
return isset($element['display_id']) ? $element['display_id'] : FALSE;
}
}