I
I
Igor2017-09-01 23:23:49
Drupal
Igor, 2017-09-01 23:23:49

How to create widget select2 for Drupal8?

How to create widget select2 for Drupal8?
I want to make a list of currencies with flags according to my table
Installed using the command composer require select2/select2
In the widget for formElement I write:

. . . 
  $element += [
      '#type' => 'select2',
      '#default_value' => isset($items[$delta]->value) ? $items[$delta]->value : '',
      '#size' => 1,
      '#maxlength' => 255,
    '#options' => $options,
    '#options_attributes' => $options_attributes,
    '#empty' => $this->t('No currencies found'),
      '#element_validate' => [
        [$this, 'CurrencyValidation'],
      ],
    ];
. . .

What's wrong? Tell...

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question