You are here

public function WebformEntityReferenceWidgetTrait::settingsForm in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Plugin/Field/FieldWidget/WebformEntityReferenceWidgetTrait.php \Drupal\webform\Plugin\Field\FieldWidget\WebformEntityReferenceWidgetTrait::settingsForm()

File

src/Plugin/Field/FieldWidget/WebformEntityReferenceWidgetTrait.php, line 50

Class

WebformEntityReferenceWidgetTrait
Trait for webform entity reference and autocomplete widget.

Namespace

Drupal\webform\Plugin\Field\FieldWidget

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $element = parent::settingsForm($form, $form_state);
  $element['default_data'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Enable default submission data (YAML)'),
    '#description' => $this
      ->t('If checked, site builders will be able to define default submission data (YAML)'),
    '#default_value' => $this
      ->getSetting('default_data'),
  ];
  if ($this
    ->getSetting('webforms') !== NULL) {
    $element['webforms'] = [
      '#type' => 'webform_entity_select',
      '#title' => $this
        ->t('Select webform'),
      '#description' => $this
        ->t('If left blank all webforms will be listed in the select menu.'),
      '#select2' => TRUE,
      '#multiple' => TRUE,
      '#target_type' => 'webform',
      '#selection_handler' => 'default:webform',
      '#default_value' => $this
        ->getSetting('webforms'),
    ];
    $this->elementManager
      ->processElement($element['webforms']);
  }
  return $element;
}