Restrict vocabulary on entity_autocomplete form field targeting taxonomy terms I'm creating a form with an entity_autocomplete field targeting taxonomy terms, and I would like to restrict it to a certain vocabulary. Is there a way to do that with '#selection_settings'? I can't find any example.

This is the code I am using.

$form['p_cat_ac'] = array(
    '#type' =&gt; 'entity_autocomplete',
    '#title' =&gt; t('Product Category'),
    '#target_type' =&gt; 'taxonomy_term',
    '#selection_settings' =&gt; [
        'include_anonymous' =&gt; FALSE,
    ],
);
The vocabulary is the taxonomy term's bundle, so you just have to add a target_bundles array to the #selection_settings entry. In my case the desired vocabulary ID is 'category'.

$form['p_cat_ac'] = array(
    '#type' =&gt; 'entity_autocomplete',
    '#title' =&gt; t('Product Category'),
    '#target_type' =&gt; 'taxonomy_term',
    '#selection_settings' =&gt; [
        'include_anonymous' =&gt; FALSE,
        'target_bundles' =&gt; array('category'),
    ],
);