We have webforms that use optgroups in a Drupal 7 bilingual website. We are currently migrating them to Drupal 8 and we found that the way webform is handling optgroups makes it difficult to maintain these forms. We are now using taxonomy terms to populate the select options and making the top level terms the optgroups, not selectable by the end users. In doing so we would need a minor change to the current term select code in 8.x-5.x.

Comments

theterencechan created an issue. See original summary.

theterencechan’s picture

jrockowitz’s picture

Status: Active » Closed (won't fix)

Not having the top level of selectable is a unique case and I think this would confuse most users.

I recommend looking at https://www.drupal.org/project/webform_shs

theterencechan’s picture

webform_shs does not provide optgroup. The UX does not meet our need, because it will force to user to at least select twice to get to what he wants. as well it does not provide the big picture.

jrockowitz’s picture

Are you trying to only require users to select the lowest level term?

We could explore adding the ability to disable all parent terms. Disabling options for a select menu would have to be done via JavaScript.

theterencechan’s picture

All I was trying to do was emulating optgroup in a select by using taxonomy term, so content editors can maintain the list as well as translating the optgroup and option labels, without the need to deploy the webform yml, which does not work for language translation by the way. No worry, I can do the same functionality with a plugin in a custom module instead.