. . .
$element += [
'#type' => 'select',
'#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'],
],
];
. . .
composer require select2/select2
. . .
$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'],
],
];
. . .
$entity = \Drupal::entityTypeManager()->getStorage('user')->create(array());
$formObject = \Drupal::entityTypeManager()
->getFormObject('user', 'register')
->setEntity($entity);
$form = \Drupal::formBuilder()->getForm($formObject);
$txtblockReg = \Drupal::service('renderer')->render($form);
// основной блок
$node = $node . '<div class="CenterBlock" id="UnregMainBlock">';
$node = $node . '<div id="RegistrationBlock">';
$node = $node . $txtblockReg;
$node = $node . '</div>';
$node = $node . '</div>';
return array(
'#type' => 'markup',
'#markup' => $node,
);