public function EntityAutocomplete::prepare in YAML Form 8
Prepare an element to be rendered within a form.
Parameters
array $element: An element.
\Drupal\yamlform\YamlFormSubmissionInterface $yamlform_submission: A form submission.
Overrides YamlFormElementBase::prepare
File
- src/Plugin/ YamlFormElement/ EntityAutocomplete.php, line 65 
Class
- EntityAutocomplete
- Provides a 'entity_autocomplete' element.
Namespace
Drupal\yamlform\Plugin\YamlFormElementCode
public function prepare(array &$element, YamlFormSubmissionInterface $yamlform_submission) {
  parent::prepare($element, $yamlform_submission);
  // If #tags (aka multiple entities) use #after_builder to set #element_value
  // which must be executed after
  // \Drupal\Core\Entity\Element\EntityAutocomplete::validateEntityAutocomplete().
  if ($this
    ->hasMultipleValues($element)) {
    $element['#after_build'][] = [
      get_class($this),
      'afterBuildEntityAutocomplete',
    ];
  }
  // If selection handler include auto_create when need to also set it for
  // the $element.
  // @see \Drupal\Core\Entity\Element\EntityAutocomplete::validateEntityAutocomplete
  if (!empty($element['#selection_settings']['auto_create_bundle'])) {
    $element['#autocreate']['bundle'] = $element['#selection_settings']['auto_create_bundle'];
  }
}