I'm using the great hook to create a pre-built option list from a list of organisation nodes on a client site that allows forms to be built without having to 'hard code' the organisations in the select. I'm using this with the options_elements module to present the choices in a nice way.

That was working all well and good until I tried to figure out how to set a default value which would be different for each user (users are associated with an organisation primarily, but could select a different one on this particular form). I used the patch from http://drupal.org/node/428982#comment-3785684 to be able to generate the tokens I needed, but couldn't figure out how to actually use them in a select. And then realised after reading some code I couldn't use them the way it was working currently.

So, I created the attached patch to fix this little use-case and it seems to be working quite nicely on my site. Would be great if it made it into the next version!

Shawn

CommentFileSizeAuthor
webform_6.x-3.4_cbd-2010-12-20.patch1.72 KBsdsheridan

Comments

quicksketch’s picture

Status: Active » Needs work

I'm unclear as to what this new field is doing. Why wouldn't you use the already-existing field to set a default value? It's already run through tokens as it is currently.

sdsheridan’s picture

Alas, with options_elements, the exiting field seems to be ignored. I tried switching to "manual entry", and then populating the default with a token, but to no avail. I have to confess I did not do a full trace through to see where / how the default was being trashed, but it was. And, at the very least, even if the existing field did work with manual entry, the way to make it work would be rather convoluted. Now maybe this is only an issue if one is using options_elements...

quicksketch’s picture

Status: Needs work » Closed (duplicate)

This should be fixed in Options Element, not Webform. See the Options Element issue over in #1007532: Setting default select option with %get[].