0

How to configure chosen field on Form API with drupal 8. I have already installed chosen and it's works in User Interface and not in form API.

This peace of code doesn't work:

          $form['tags'] = array(
        '#type' => 'entity_autocomplete', 
       '#chosen' => TRUE,
        '#target_type' => 'taxonomy_term',
        '#selection_settings' => ['target_bundles' => ['tags']],
        '#title' => ('Tags'), 
        '#empty_value' => '' 
       ;

1 Answer 1

0

I guess you can't because you are using an autocomplete widget, but the project page states:

Chosen uses the Chosen jQuery plugin to make your elements more user-friendly.

So you have to refactor your form to use a select element, not an autocomplete.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.