Just wondering why a mandatory select listbox has a 'select...' option...?
I would have thought that by making a select listbox mandatory it would only display the options you entered, especially if you also set a default value, which I have.

Any way to get rid of the 'select...' option?

CommentFileSizeAuthor
#8 webform-598742-8.patch689 bytesAnonymous (not verified)
#4 webform-598742-4.patch656 bytesAnonymous (not verified)

Comments

t-wheeler’s picture

Using 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.

Anonymous’s picture

That's fine, but I'm referring to the 'select...' (literally called that) option that the user sees if they expand the drop-down box...

osman’s picture

Hi @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,

Anonymous’s picture

Version: 6.x-2.7 » 6.x-2.x-dev
Category: support » bug
Status: Active » Needs review
StatusFileSize
new656 bytes

Here'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.

quicksketch’s picture

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).

Anonymous’s picture

Status: Needs review » Needs work

That 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...

quicksketch’s picture

The $component['value'] property is the default value for a field.

Anonymous’s picture

Status: Needs work » Needs review
StatusFileSize
new689 bytes

Hmm, 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 ;)

quicksketch’s picture

Status: Needs review » Fixed

Perfect BWPanda, committed to all branches.

Status: Fixed » Closed (fixed)

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

teamA’s picture

Hi,

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?

danny_joris’s picture

Hi 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

tobedeleted’s picture

Status: Closed (fixed) » Active

I 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.

quicksketch’s picture

Otherwise there is no benefit to having a default value option.

If 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).

quicksketch’s picture

Status: Active » Closed (fixed)
tomsm’s picture

Status: Active » Closed (fixed)

I 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.

tomsm’s picture

Status: Closed (fixed) » Active

Maybe the issue http://drupal.org/node/853836 also applies to this one.

Reopen...?

quicksketch’s picture

Thanks for opening the new issue. Let's discuss your new issue there.