- Issue created by @hktang
- Status changed to Closed: works as designed
28 days ago 12:40pm 24 November 2024 - πΊπΈUnited States jrockowitz Brooklyn, NY
The webform module does not support the autocreation of entity reference via the UI or YAML.
auto_create: true
.There are no taxonomy terms matching "Test2".
The form is in this shape:
tag:
'#type': entity_autocomplete
'#title': Tag
'#target_type': taxonomy_term
'#selection_handler': 'default:taxonomy_term'
'#selection_settings':
target_bundles:
tags: tags
sort:
field: name
direction: asc
auto_create: true
auto_create_bundle: ''
I am guessing the issue comes from the following validation code.
$form_state->getValue($element['#parents'])
is empty. $element['#value']
holds the text value of the new/non-existing tag. But it's not used to create a new tag. /**
* Form API callback. Remove target id property and create an array of entity ids.
*/
public static function validateEntityAutocomplete(array &$element, FormStateInterface $form_state) {
// Must use ::getValue($element['#parents']) because $element['#value'] is
// not being updated.
// @see \Drupal\Core\Entity\Element\EntityAutocomplete::validateEntityAutocomplete
$value = $form_state->getValue($element['#parents']);
if (empty($value) || !is_array($value)) {
return;
}
...
Active
6.2
Code
The webform module does not support the autocreation of entity reference via the UI or YAML.