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 Answers
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.
-
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.– nehaMar 23, 2020 at 8:22
Check for the D8 module Tac Lite
-
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.– berlinerDec 15, 2021 at 9:55
hook_form_alter
orhook_form_FORM_ID_alter