From 8f2dc97df6c7c69b96e62fda8a25bc671cb939e4 Mon Sep 17 00:00:00 2001 From: Paul Pound Date: Thu, 24 Oct 2024 10:18:40 -0300 Subject: [PATCH] cleaned things up a bit --- .../FieldWidget/DisableAutocompleteWidget.php | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/Plugin/Field/FieldWidget/DisableAutocompleteWidget.php b/src/Plugin/Field/FieldWidget/DisableAutocompleteWidget.php index 76fe527..eb3e29b 100644 --- a/src/Plugin/Field/FieldWidget/DisableAutocompleteWidget.php +++ b/src/Plugin/Field/FieldWidget/DisableAutocompleteWidget.php @@ -2,7 +2,7 @@ namespace Drupal\disable_field_autocomplete\Plugin\Field\FieldWidget; -use Drupal\Core\Field\Plugin\Field\FieldWidget\EntityReferenceAutocompleteWidget; +use Drupal\controlled_access_terms\Plugin\Field\FieldWidget\TypedRelationWidget; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Field\FieldItemListInterface; @@ -17,26 +17,14 @@ use Drupal\Core\Field\FieldItemListInterface; * }, * ) */ -class DisableAutocompleteWidget extends EntityReferenceAutocompleteWidget { +class DisableAutocompleteWidget extends TypedRelationWidget { /** * {@inheritdoc} */ public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { $widget = parent::formElement($items, $delta, $element, $form, $form_state); - - $item =& $items[$delta]; - $settings = $item->getFieldDefinition()->getSettings(); - // Set the target bundles to an empty array so autocomplete does - // not find anything. We want an uncontrolled vocabulary. $widget['target_id']['#selection_settings']['target_bundles'] = []; - $widget['rel_type'] = [ - '#title' => t('Relationship Type'), - '#type' => 'select', - '#options' => $settings['rel_types'], - '#default_value' => isset($item->rel_type) ? $item->rel_type : '', - '#weight' => -1, - ]; return $widget; }