<?php public function buildForm(array $form, FormStateInterface $form_state) { $config = $this->config('custom_module'); // Define the element(s). $form['nodes'] = [ '#type' => 'entity_autocomplete', '#title' => $this->t('Select favorite articles.'), '#multiple' => 15, '#target_type' => 'node', '#selection_handler' => 'default:node', '#selection_settings' => [ 'target_bundles' => ['article' => 'article'], 'sort' => ['field' => 'title', 'direction' => 'ASC'], ], '#default_value' => $config->get('nodes'), ]; // Process the element(s). $this->elementManager->processElement($form['nodes']); // Attach behaviors. Unsaved: Warn users about unsaved changes. $form['#attributes']['class'][] = 'js-webform-unsaved'; $form['#attached']['library'][] = 'webform/webform.form.unsaved'; return parent::buildForm($form, $form_state); }