After upgrading from 2.9 to 3.0 I noticed that the select... option is missing for anonymous users.

I have a select list that has a default token value: %profile[profile_title]

I read this at issue: http://drupal.org/node/598742 #5:
I'd be willing to remove the "select...", but only if the field is both mandatory AND a default value is already provided.

But anonymous users have not filled in this profile value, so when they open the webform, "select..." should appear instead of the first valid option.

CommentFileSizeAuthor
#4 webform_select_empty_default.patch725 bytesquicksketch

Comments

tomsm’s picture

Version: 7.x-3.0-beta6 » 6.x-3.0-beta6

sorry, selected wrong version

tomsm’s picture

Component: Code » User interface
quicksketch’s picture

Thanks for the great bug report tomsm. I'll look into this when I get the chance.

quicksketch’s picture

Title: mandatory select listbox "select..." option missing for anonymous user » Mandatory select listbox "select..." option missing when default value is NULL
Status: Active » Fixed
StatusFileSize
new725 bytes

I found this applies not only to anonymous users, but also to authenticated users when they haven't filled out a profile value. The fix is really easy though, since we already have the parsed default value available as a variable, we just need to check it instead of the raw default.

Committed the attached patch. Please let me know if you encounter any other troubles with the default "select..." option.

tomsm’s picture

I have tested 6.x-3.1 and the issue is fixed. Thanks!

tomsm’s picture

Priority: Major » Normal

I have another problem that might be related to this issue:

http://drupal.org/node/885454 might be a duplicate of this issue...?

Webform always fills in the first item of a select list as default value.

When I remove %profile[key] as default value for the webform select list, the first item is still used as default value.
This should be "Select..." as it is for anonymous users.

tomsm’s picture

Priority: Normal » Major
Status: Fixed » Active
quicksketch’s picture

Status: Active » Fixed

There are several different issues, regarding the first item being selected if the first item has a key of zero. Let's consolidate this new problem over in #885454: First item of select lists selected as default if no default is set.

Status: Fixed » Closed (fixed)

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

sibert’s picture

Version: 6.x-3.0-beta6 » 7.x-3.11
Priority: Normal » Major
Status: Closed (fixed) » Active

I'd be willing to remove the "select...", but only if the field is both mandatory AND a default value is already provided. Often it's helpful to not provide use the first value on a required field because it tends to suggest to the user that the first answer should be used, which might not be the case in a situation where you're asking for a user's opinion for example (i.e. Bad, Okay, Good, Great).

In previous version of Webform this worked as above quoted. Updating to 7.x-3.11 this behaviour has changed to always select the first line in a select field, which is really confusing for the user. I have search this subforum for restore the old behaviour, but I have not found anything.

Thanks in advance for any clue to fix this!

quicksketch’s picture

Priority: Major » Normal
Status: Active » Closed (fixed)

I agree, but let's reconvene in the new issue for fixing this in #1078750: Options for "- Select -" or "- None -" not automatically added.