CountryFlagAutocompleteWidget.php in Flags 8
File
flags_country/src/Plugin/Field/FieldWidget/CountryFlagAutocompleteWidget.php
View source
<?php
namespace Drupal\flags_country\Plugin\Field\FieldWidget;
use Drupal\country\Plugin\Field\FieldWidget\CountryAutocompleteWidget;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Form\FormStateInterface;
class CountryFlagAutocompleteWidget extends CountryAutocompleteWidget {
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
$element = parent::formElement($items, $delta, $element, $form, $form_state);
$element['value']['#autocomplete_route_name'] = 'flags_country.country_autocomplete';
$element['value']['#attached'] = array(
'library' => array(
'flags/flags',
),
);
return $element;
}
}