public function EntityAutocomplete::prepare in Webform 8.5
Same name and namespace in other branches
- 6.x src/Plugin/WebformElement/EntityAutocomplete.php \Drupal\webform\Plugin\WebformElement\EntityAutocomplete::prepare()
Prepare an element to be rendered within a webform.
Parameters
array $element: An element.
\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission. Webform submission is optional since it is not used by composite sub elements.
Overrides WebformElementBase::prepare
See also
\Drupal\webform\Element\WebformCompositeBase::processWebformComposite
File
- src/
Plugin/ WebformElement/ EntityAutocomplete.php, line 99
Class
- EntityAutocomplete
- Provides a 'entity_autocomplete' element.
Namespace
Drupal\webform\Plugin\WebformElementCode
public function prepare(array &$element, WebformSubmissionInterface $webform_submission = NULL) {
parent::prepare($element, $webform_submission);
// Remove maxlength.
$element['#maxlength'] = NULL;
// 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']) && !empty($element['#selection_settings']['auto_create_bundle'])) {
$element['#autocreate']['bundle'] = $element['#selection_settings']['auto_create_bundle'];
}
}