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.

  • 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 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 at 8:11
0

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. – neha Mar 23 at 8:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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