Say I set a 'selection' field, with the possible values :
value_1
value_2
value_3,
and set this field as requested (check "The user must enter a value".)

At edition-time, the drop down list shows
--
value_1
value_2
value_3,
with '--' as a a selectionable (and selected by default) value.

In a way, It is equivalent to 'no value', and therefore cancels the "requested" specification.

Comments

kuahyeow’s picture

Version: 4.7.0-beta2 » 4.6.3

Ditto that for version 4.6.3 as well...

It makes no sense to require a value, but provide an empty option

yched’s picture

Version: 4.6.3 » 4.7.0-beta2
Status: Active » Needs review
StatusFileSize
new2.01 KB

This patch corrects this behaviour :
The default '--' option is set as the first option only if 'The user must enter a value.' is not checked.

During the validation of the field creation / edition form, the patch also checks that 'selection options' is not empty if the field is to be 'required'

A hidden field containing the 'type' of the involved field ('selection', 'list', 'checkbox') has been added to the field creation / edition form in order to make that validation step.
This field should probably use '#type' => 'value' instead of '#type' => 'hidden', but i can't seem to have '#type' => 'value' work...

yched’s picture

Version: 4.7.0-beta2 » 4.6.5
StatusFileSize
new2.59 KB

Here is the patch for 4.6.5

yched’s picture

Version: 4.6.5 » 4.7.0-beta3
StatusFileSize
new1.49 KB

re-rolled for current head

yched’s picture

StatusFileSize
new1.49 KB

And again

moshe weitzman’s picture

Status: Needs review » Needs work

nice patch. however, i'm pretty sure that you don't need a hidden field here. you can inspect $form and know if the field was a selection type.

yched’s picture

I don't have access to $form in the profile_validate_form function.
The only available info at this time is $edit (= $_POST['edit']), that lists the values of the fields

moshe weitzman’s picture

Status: Needs work » Reviewed & tested by the community

OK, I thought this module was fully converted to form submit module but it isn't. That conversion can wait until 4.8 unless someone out there is up for it. RTC

dries’s picture

Mmm. Not sure this is RTBC. Looks hairy at first glance.

moshe weitzman’s picture

Status: Reviewed & tested by the community » Needs review

ok, then lets get some more reviewers on it.

yched’s picture

StatusFileSize
new1.49 KB

synched with HEAD.

I think this patch looks hairy because profile.module currently IS hairy.

As Moshe pointed out, profile.module could do with a good overhaul, but
a) now might be a little late in 4.7 release timeline
b) I don't have the time (just like many people...) an probably no the skills to go for it myself (lame excuse ?)

I can't think right now of another way to patch this issue, but any suggestions are welcome.
This module is in core, and IMO this issue (and that other one, BTW), _have_ to be adressed in the final 4.7 release...

moshe weitzman’s picture

Status: Needs review » Needs work

i think we can never show the -- option, even when not required. isn't that how optional vocabs render?

yched’s picture

StatusFileSize
new1.5 KB

optional vocabs render as dropdown selects, that do have '' as a first choice.

The updated patch keeps coherent with taxonomy and sets '' as the 'empty option' for a profile select field.

yched’s picture

Sorry, I should have previewed - The previous post should read :

optional vocabs render as dropdown selects, that do have <none> as a first choice.

The updated patch keeps coherent with taxonomy and sets <none> as the 'empty option' for a profile select field.

jose reyero’s picture

I think there's some difference between 'The user must enter a value' and providing a default value for the field.

I mean, even when the field is required, it makes a lot of sense to show a default blank value to the user. But it also makes sense to have the validation and produce an error for that field if the user didn't select an actual value.

So, why cant we keep that default value ('--') and add only the validation part?

yched’s picture

StatusFileSize
new1.02 KB

Now that profile.module is fully FormsAPI-compliant, this patch is really straightforward
It does two things :

  • add the '--' (none) option only if the field is not "required"
  • set the 'selection options' textarea on the field creation/edition form as "required"

Jose A Reyero : sorry, but that makes no sense to me. If you specify that "the user must enter a value", it's bad UI design to provide an 'empty' option in the list, that will lead him to validation rejection.
Look at the way taxonomy handles "required" vocabularies. We have to stick with that - you can't multiply UI "philosophies" througout the interface, or you'll confuse the user.

yched’s picture

Version: 4.7.0-beta3 » x.y.z
Status: Needs work » Needs review
jose reyero’s picture

> Jose A Reyero : sorry, but that makes no sense to me. If you specify that "the user must enter a value", it's bad UI design to provide an 'empty' option in the list, that will lead him to validation rejection.

Of course, if the user doesn't enter a value there will be a validation rejection. That's what validation is meant for.

I.e: You want to have a mandatory field for user registration that is "Country" that means you actually want to know where your users come from. If you provide a default value for that field, then you'll end up finding that half of your users happen to be from that default country, whatever it is.

> Look at the way taxonomy handles "required" vocabularies. We have to stick with that - you can't multiply UI "philosophies" througout the interface, or you'll confuse the user.

Mandatory field is not the same as 'default value' for a field. That is weak UI design whatever the 'philosophy' is.

The fact that vocabularies doesnt have this feature -which would be desirable- doesnt mean we have to worsen the interface for user profiles.

Jaza’s picture

@Jose: I understand what you're saying, but I'm afraid I don't agree with your argument. IMO, the way that taxonomy handles it is the best way, from a usability point of view. You are saying that required fields should still have a '<none>' option, because then if users don't choose an option, they get a validation error. But many users take the presence of the 'none' option as an indication that the field is NOT required, and so putting it in required fields will only confuse those users. Additionally, users of many Drupal sites have already had a long time to get used to the lack of 'none' in required vocabulary select fields, and putting it in profile fields will confuse those users as well.

I can also think of a number of cases where having a 'none' option in a required profile field would be completely inappropriate. For example, when a required field only has one option, the user still has to manually select it, which they shouldn't have to do. And another example, when the site admin has put the most popular option at the top of the list, so that 90% of users can leave the field at its default.

yched’s picture

Status: Needs review » Fixed

A similar patch has been committed here

Anonymous’s picture

Status: Fixed » Closed (fixed)
ekrispin’s picture

Version: x.y.z » 5.1
Category: bug » feature

The solution provided in the fix for 4.7 (which is now a part of 5.x) doesn't do the job! Now, when having "The user must enter a value" checked for the country selection list field , most of the registrating users leave the default value (first optional value in the list) of the country field as it is ("Abkahazia") and it means = the field is practically still optional!

We must have the "--" option also for mandatory fields AND REGARD THIS VALUE as the same as the case when the user did NOT feel the field (which is exactly what happens).

BioALIEN’s picture

Version: 5.1 » 6.13
Status: Closed (fixed) » Active

Sorry to say, D6 still lack's this "feature" although it feels more like a UI bug. I have just tested ekrispin's concern and yes I believe he is right, by making this field required, I don't automatically want to preselect the first entry. There should be validation in place to force a user to select an option without having one option preselected.

Drupal's own registration form has carried out the fix: http://drupal.org/user/register
In the Country select list, we have <not specified> as the first option.

What's more annoying, the profile.module doesn't support key/label such as: USD|U.S. Dollar (USD) inline with everywhere else on Drupal. If this was the case, we can fix this issue with a simple --|Please specify

I found an issue to get key/label into D6 #375307: Allow key|value pairs in selection fields of profile.module but not sure if this will accept null values.

damien tournoud’s picture

Version: 6.13 » 7.x-dev
Status: Active » Closed (won't fix)

5.x and 6.x are not open to feature request. For Drupal 7 onward, the profile module is obsolete. Won't fix.

pauln600’s picture

Version: 7.x-dev » 6.x-dev
Category: feature » bug
Status: Closed (won't fix) » Needs work

I just encountered this bug - and the way it works now is a bug - and the conclusion to this thread is pretty strange. If I set a required value on a select list, and the list doesn't have a no-value option, the first item on the list will automatically be posted if the poster doesn't change it. That is, IMHO, totally bizarre behaviour. The whole purpose of the required value is to force the poster to take some sensible action, not cause damage (i.e., post a meaningless value) if they don't. The way this is set up now is a bug.

anrikun’s picture

Title: 'selection' field : default value '--' should'nt be there for required fields » No option should be selected by default for required select fields
Status: Needs work » Needs review
StatusFileSize
new419 bytes

@pauln600: I agree with you.
Here is a patch that fixes this issue.

Status: Needs review » Needs work

The last submitted patch, profile.module_19.patch, failed testing.

anrikun’s picture

Status: Needs work » Active

"needs review" triggers a simpletest on patch from #16.
Strange...
Let's use "active" then...

deepsoulstarfish’s picture

Subscribe: It would really be great to get a fix for this bug. Some projects are not ready for Drupal 7 (or Drupal 7 is not ready, I'm not sure which way around it is).

chinita7’s picture

I applied this patch to core profile module and it works on my site.

Status: Active » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.