Skip to content
Snippets Groups Projects
Commit fdb1fb92 authored by Lee Rowlands's avatar Lee Rowlands
Browse files

Issue #2863534 by larowlan: Prevent selection of parents that user has no access to

parent dbf171f9
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@ namespace Drupal\entity_hierarchy\Plugin\Field\FieldWidget;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\Plugin\Field\FieldWidget\EntityReferenceAutocompleteWidget;
use Symfony\Component\Validator\ConstraintViolationInterface;
/**
* Widget that uses autocomplete.
......@@ -21,6 +22,13 @@ use Drupal\Core\Field\Plugin\Field\FieldWidget\EntityReferenceAutocompleteWidget
class EntityReferenceHierarchyAutocomplete extends EntityReferenceAutocompleteWidget {
const HIDE_WEIGHT = 'hide_weight';
/**
* {@inheritdoc}
*/
public function errorElement(array $element, ConstraintViolationInterface $error, array $form, FormStateInterface $form_state) {
return isset($element[0]['target_id']) ? $element[0]['target_id'] : FALSE;
}
/**
* {@inheritdoc}
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment