|
|
@ -2,7 +2,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
namespace Drupal\disable_field_autocomplete\Plugin\Field\FieldWidget; |
|
|
|
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\Form\FormStateInterface; |
|
|
|
use Drupal\Core\Field\FieldItemListInterface; |
|
|
|
use Drupal\Core\Field\FieldItemListInterface; |
|
|
|
|
|
|
|
|
|
|
@ -17,26 +17,14 @@ use Drupal\Core\Field\FieldItemListInterface; |
|
|
|
* }, |
|
|
|
* }, |
|
|
|
* ) |
|
|
|
* ) |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
class DisableAutocompleteWidget extends EntityReferenceAutocompleteWidget { |
|
|
|
class DisableAutocompleteWidget extends TypedRelationWidget { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* {@inheritdoc} |
|
|
|
* {@inheritdoc} |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { |
|
|
|
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { |
|
|
|
$widget = parent::formElement($items, $delta, $element, $form, $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['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; |
|
|
|
return $widget; |
|
|
|
} |
|
|
|
} |
|
|
|