Reputation: 23
I have a very interesting task.
In Wagtail Admin we create a new page of products. Here we specify of course the title, choicefield1 and choicefield2. The choicefield1 is group of types and choicefield2 is a group of values for each value in choicefield1.
What I need is, when selecting something from choicefield1, dynamic show only the values in choicefield2 that are in the group selected in choicefield1, instead of displaying all groups.
Also transform this to this. Images are just for example, but I need this in Wagtail Admin, when creating new page.
How is this possible?
Upvotes: 1
Views: 938
Reputation: 390
If the field is located in a block you could specify a custom template for it. In this template you could write a javascript which converts the FULL select with <optgroup>
elements to 2 selects of which the first lists the <optgroup>
labels and the second only displays the associated <option>
elements.
For pages you could simply use a hook to add javascript to the interface and modify the select.
See the documentation for more information on how to customise a StructBlock
.
Upvotes: 1