[solved] Pro Forms Terms Query in select field (Child Terms)

Hi,

I try to make a post submit form (nestable) where the user can select a taxonomy term.
I want to fill the options via query loop. So far so good.

My Taxonomy is hierarchical so some of the terms are parent and have some child terms.

I expected that the select field will show the terms like this:

Parent1
-Child1 of Parent1
-Child2 of Parent1
Parent2
Parent3
Parent4
-Child1 of Parent4
-Child2 of Parent4
-Child3 of Parent4
-Child4 of Parent4

But I can’t get it work.

Has anyone the secret hint for me?
Kind regards,
Ole

A select field will not automatically create groups for you. You can use the “Optgroup” element to create the needed groups for your taxonomy parents. Then, loop trough the children and add them as “Option”. So “Optiongroup” takes tha parent, while “Option” takes the child.

Hi @Daniele,

Thank for quick reply.

I got it :slight_smile:

1 Like