0

In a node edit/add form, I need to show a field with dropdown/select list options (Cardinality unlimited). I do not want all the taxonomy terms of that vocabulary to appear. I want to show certain terms. The vocabulary has 2 level hierarchy. First dropdown in the form element shows only parent terms. On selecting parent term from the dropdown, certain child elements should show in the second dropdown.

2
  • i think there is no module for such feature, you should do it in custom code, by implementing hook_form_alter or hook_form_FORM_ID_alter
    – berramou
    Mar 22, 2020 at 23:43
  • 1) Hook form alter is not working for altering options for widget. Hook form alter does not work because these options are again rebuild after the form is altered. 2) hook_field_widget_form_alter is not altering the options.
    – neha
    Mar 23, 2020 at 8:11

2 Answers 2

1

You seem to be asking 2 questions here:

  • Restricting Terms: You can edit the entity reference field's Reference method to use a new custom view that filters only the criteria you're looking for.
  • Parent/Child Widget: The Hierarchical Select did have this widget functionality in D7, in D8 there are a few modules out there, like Simple hierarchical select & Client-side hierarchical select, that have similar dual-selection functionality.
1
  • These both "Restricting Terms" and "Parent/Child Widget:" do not work simutaneously. Simple hierarchical select and Client side hierarchical select are not working when I am using with views entity reference. Either restricting term functionality work OR the parent child.
    – neha
    Mar 23, 2020 at 8:22
-1

Check for the D8 module Tac Lite

1
  • Welcome to Drupal Answers! Please add information on how this module solves the original question. Please also refer to the Help Center to see what answers are acceptable on this site.
    – berliner
    Dec 15, 2021 at 9:55

Your Answer

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

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