0

I have a huge hierarchical vocabulary of terms and adding a new child to a specific term can be hard using the default multi-value select list widget.

Can I use an autocomplete widget or -better- an entity browser instead?

2 Answers 2

1

Solved myself using Select2 contrib module + very little customization in my module:

function my_module_form_alter(&$form, FormStateInterface $form_state, $form_id) {

  if ($form_id == 'taxonomy_term_myvocabulary_form') {
    // Show parent select as select2 (if enabled)
    if (\Drupal::moduleHandler()->moduleExists('select2')) {
      $form['relations']['parent']['#type'] = 'select2';
    }
  }
}

This is the result:

screenshot

Hope this helps someone.

0

I'm not sure if it would integrate with that widget automatically, but I really like Chosen. Doesn't work on mobile though.

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.