Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Thanks very much for your work on adding #2853164: Hierarchical entity select. However, the UX wasn't exactly what the client had in mind when faced with allowing the user to select multiple categories, even with the jquery Select.
They requested the ability to have checkboxes and as you check a term, its child terms become visible.
The attached patch adds this functionality, though is currently without tests.
Comment | File | Size | Author |
---|---|---|---|
#15 | hierarchical_taxonomy-2864400-15.patch | 121.75 KB | jrockowitz |
| |||
#13 | hierarchical_taxonomy-2864400-12.patch | 123.51 KB | jrockowitz |
#9 | hierarchical_taxonomy-2864400-7.patch | 106.92 KB | jrockowitz |
#9 | Screen Shot 2017-04-03 at 4.36.16 PM.png | 48.1 KB | jrockowitz |
webform-hierarchical-term-checkboxes.patch | 7.09 KB | stella | |
Comments
Comment #2
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commented@stella Adding this element makes complete sense to me.
Besides tests, we should consider....
Notes.
Comment #3
stella CreditAttribution: stella at Annertech commentedI think Radios would be harder to achieve as you can only select 1 radio button normally. So clicking through an expanding set of child terms which are all part of one radios set, wouldn't be good ux, no?
Though you probably want to be able to force them to click through one path and only select one child term at the very end (and not the entire tree). Maybe the cshs module approach to that is better? it's a drop-down which spawns a secondary drop-down for child terms which in turn spawns another for grandchildren, etc. And if you want to allow more than one term to be selected you click 'add more' to get another set.
As for the scrollable thing - as long as it's an optional feature, i'm ok with that.
Comment #4
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI think creating a WebformTermBase class is the key task and creating a WebformTermRadios element can be handled in a new ticket.
Comment #5
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commented@stella I am going to do a little work on the patch.
Comment #9
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commented@stella I added support for the #scroll property and set up a WebformTermReference trait. I ran into some "out of sync" exported configuration so the attached patch is updating all exported config.
Below is a screenshot of the #scroll adding scrolling to term checkboxes.
Right now, I can't see supporting the custom #states hide/show logic but below is your code moved into a custom hook, that you can use to maintain this functionality for your client.
I am going to write some tests and commit this improvement.
In the long term, it would be really cool if we could support something like https://www.jstree.com/ for selecting hierarchical taxonomy terms.
Comment #10
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commented@stella I also think it should be possible to add support to the webform module for the cshs module which includes a dedicated form element.
Comment #13
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #15
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #17
stella CreditAttribution: stella at Annertech commentedThe idea behind the states thing is to reduce the length of checkboxes visible at any one point, so the user only sees the ones relevant to them. They have to click on a term to see its children, and then can drill down to the child term they want. My requirement was they had to select each parent along the way to get to the final term they wanted to select.
The taxonomy I have is going to grow quite large, 100 or so terms, so the client only wanted top level ones visible, and then clicked down through to refine the categorisation of the event that was being submitted on the form. They have about 8 top level terms, and the rest are more specialised as you drill down.
Comment #18
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commented@stella That requirement makes sense. I remember a similar feature being included in the hierarchical select module. I think the UX would need to more refined before being included in the Webform core module. For example, any term with sub-terms should have an open/close indicator, like an arrow. Hopefully, the webform module can just integrate with one of the available hierarchical selection module.
For now, the scrolling behavior will allow for 100+ terms to be displayed.
BTW, this custom hide/show code could be moved to a recipe.
Comment #20
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commented