- Issue created by @jonathanshaw
I found it very difficult to figure out how to limit the cardinality in an 'entity_autocomplete_tagify' element in a form.
The correct solution is:
$form['selection']['select'] = [
'#type' => 'entity_autocomplete_tagify',
'#target_type' => 'node',
'#cardinality' => 1,
'#identifier' => 'some_id',
'#attributes' => ['class' => 'some_id']
];
The docs for this element seem flawed, and the code could probably support this use case better.
(1) There's no mention of the '#cardinality' property in the docs.
(2) The docs mention the '#tags' property that may not exist.
(3) The docs say the identifier is optional, but it's not if #cardinality > 0.
(4) The docs don't explain the identifer has to be set as a class or id.
(5) Could we provide a default identifier on the element if none is specified? e.g. give a random string identifer of the form tagifier_id_j65b5b and set that as a class on the element?
Fix the docs, provide better validation or defaults in the element to prevent javascript errors.
None.
None.
None.
Active
1.2
Code