If I create a new select component, use "Load a pre-built option list", and use a pre-built option list that contains a group, Options Element does not display properly because it is configured to not allow groups. The problem is that #optgroups is set based on the value of aslist, but this doesn't get updated when one chooses the pre-built option list.

The attached patch fixes it by always setting #optgroups to TRUE. This is fine because the user is always allowed to use groups. Current behavior already is that if the user uses groups, then aslist is set TRUE when the component is saved.

Comments

quicksketch’s picture

Thanks for the report and patch!

This is fine because the user is always allowed to use groups.

I don't think this is always the case. Groups are not allowed if assembling radio buttons or checkboxes (in other words if "aslist" is FALSE). Perhaps adding validation to the form would be the right thing to prevent the conflict in settings.

Liam Morland’s picture

What I mean is that a select component can always handle groups, it just has to use a select element if they exist. Webform already sets aslist automatically in some situations. As it is now, if a person wants to create a select component with groups, they need to make the component, set aslist, and save, then re-edit the component to add the options with group. With my patch, they could just create and set the options with groups. When they save, they'll be told that aslist has been set.

Liam Morland’s picture

If Options Element is not installed and one tries to use groups with radio buttons or checkboxes, Webform sets aslist = TRUE automatically. It should do the same when Options Element is installed instead of going to a broken state.

Liam Morland’s picture

Do you have another suggestion about how this patch could be done?

Liam Morland’s picture

What sort of validation do you suggest adding? If the user enters an option which starts with "<", they get an error? (Only, of course, if Options Element is being used; otherwise aslist is already set automatically.)

Liam Morland’s picture

StatusFileSize
new532 bytes

This problem still exists. Reroll.

quicksketch’s picture

What sort of validation do you suggest adding?

Hi Liam, sorry I wasn't avoiding this patch in particular, I just haven't been in the Webform queue for a long time. The validation I was suggesting was that if you attempt to use an option group in your list of options, but the checkbox for "Listbox" is not checked, then a validation error is thrown.

(Only, of course, if Options Element is being used; otherwise aslist is already set automatically.)

Ah, I hadn't remembered that we were doing this already. In that case, it seems like it would make the most sense if we made Options Element lists work the same way, and if a group is created, we automatically enable "aslist", just like we do for the non-Options Element version.

Liam Morland’s picture

Thanks, Nathan. That is what this patch does.

quicksketch’s picture

Excellent, I'm doing an on-site this week and I'll be taking another run through the issue queue on the weekend. Thanks Liam for all your continued work on Webform.

quicksketch’s picture

Status:Needs review» Fixed

Thanks, works as advertised (of course)! Committed to 7.x-4.x.

Liam Morland’s picture

Thank you!

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.