I have a config entity form that has a taxonomy field, and it currently works with 1 term
$form['integration'] = array(
'#type' => 'entity_autocomplete',
'#title' => 'Integration',
'#required' => TRUE,
'#target_type' => 'taxonomy_term',
'#default_value' => $entity->getIntegration(),
'#selection_settings' => array(
'target_bundles' => array(
'integration',
),
),
);
That works fine, but I need to be able to select multiple terms, I've tried setting '#cardinality' => -1
, but it's only allowing 1 element. I added a taxonomy field with unlimited cardinality to a content type, then set a breakpoint on the form to see how it was being set up for the page rendering. It looks like it creates a container
form element, then I assume iterates over an array containing all the terms?
I would have thought there would be a way to set the cardinality of an element by making use of field widgets on the config form page, but I'm not sure that's possible.