Closed (fixed)
Project:
Webform
Version:
6.x-2.x-dev
Component:
User interface
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Anonymous (not verified)
Created:
8 Oct 2009 at 02:37 UTC
Updated:
16 May 2024 at 00:50 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
t-wheeler commentedUsing an older version (2.3) but mandatory select list shows default value.
For example, in a list of provinces is this entry:
ON|Ontario
For default value I've entered:
ON
The user sees 'Ontario' in the select list.
Comment #2
Anonymous (not verified) commentedThat's fine, but I'm referring to the 'select...' (literally called that) option that the user sees if they expand the drop-down box...
Comment #3
osmanHi @BWPanda, I totally agree with you. Mandatory select field should not render "select..." as an available option.
Same issue on version 6.x-2.9, though.
@Maintainers of Webform: Wouldn't you consider this as a bug?
Thanks,
Comment #4
Anonymous (not verified) commentedHere's a patch that removes the 'select...' option if the field is mandatory. It then displays the first option by default, but this can be changed by simply setting a default value for the field.
Comment #5
quicksketchI'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).
Comment #6
Anonymous (not verified) commentedThat sounds reasonable, but the $component array doesn't have a 'default' key, so we don't know if a field has a default value assigned or not. I think this would be needed for what you're proposing. That may require a rewrite to the webform_component database schema though...
Comment #7
quicksketchThe $component['value'] property is the default value for a field.
Comment #8
Anonymous (not verified) commentedHmm, I thought that was the case and tested it, but always got a value for $component['value']. Must have been doing something wrong...
Anyway, here's an updated patch. I think I did it correctly, but the logic started to hurt my head after a while ;)
Comment #9
quicksketchPerfect BWPanda, committed to all branches.
Comment #11
teamA commentedHi,
Sorry to open this back up, but I'm a bit baffled as to why the 'Default Value' for select component in a webform doesn't become the default value? 'select...' is neither useful, nor specific. We have the option to fill out a default value, so why not have that drop directly into the first slot of a select list? I tried poking into the code but it's a bit outside my capabilities. This would seem to solve some of the other select default issues that have been raised here.
Is there a reason not to do this?
Comment #12
danny_joris commentedHi teamA,
I agree with you. It would make sense if you fill out a default value that it would override the 'select...' value.
In the meanwhile I found out that you can change the 'select...' value into anything else with a string override. This solves the problem for me for now.
Yet, an override by the default value would make more sense to me...
Cheers,
Danny
Comment #13
tobedeleted commentedI agree with teamA - the correct approach is for the default value, if set, to be presented to the user when completing the form. Otherwise there is no benefit to having a default value option.
In my view this is a bug, so I'm reactivating the issue.
Comment #14
quicksketchIf you set a default and make the field required, the "select..." option disappears. Otherwise the user may need an option to not select anything (or leaving it blank).
Comment #15
quicksketchComment #16
tomsm commentedI have a mandatory select field that has as default value a profile token: %profile[profile_title]
This field is filled in by registered users but not by anonymous users, so the default value does not apply to them.
So in this case the "select..." option must appear.
I noticed this issue after upgrading from 2.9 to 3.0 beta and I opened an issue for this.
Comment #17
tomsm commentedMaybe the issue http://drupal.org/node/853836 also applies to this one.
Reopen...?
Comment #18
quicksketchThanks for opening the new issue. Let's discuss your new issue there.