Closed (outdated)
Project:
Drupal core
Version:
6.x-dev
Component:
profile.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
20 Dec 2005 at 17:17 UTC
Updated:
2 Mar 2016 at 22:18 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
kuahyeow commentedDitto that for version 4.6.3 as well...
It makes no sense to require a value, but provide an empty option
Comment #2
yched commentedThis 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...
Comment #3
yched commentedHere is the patch for 4.6.5
Comment #4
yched commentedre-rolled for current head
Comment #5
yched commentedAnd again
Comment #6
moshe weitzman commentednice 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.
Comment #7
yched commentedI 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
Comment #8
moshe weitzman commentedOK, 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
Comment #9
dries commentedMmm. Not sure this is RTBC. Looks hairy at first glance.
Comment #10
moshe weitzman commentedok, then lets get some more reviewers on it.
Comment #11
yched commentedsynched 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...
Comment #12
moshe weitzman commentedi think we can never show the -- option, even when not required. isn't that how optional vocabs render?
Comment #13
yched commentedoptional 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.
Comment #14
yched commentedSorry, 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.Comment #15
jose reyero commentedI 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?
Comment #16
yched commentedNow that profile.module is fully FormsAPI-compliant, this patch is really straightforward
It does two things :
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.
Comment #17
yched commentedComment #18
jose reyero commented> 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.
Comment #19
Jaza commented@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.
Comment #20
yched commentedA similar patch has been committed here
Comment #21
(not verified) commentedComment #22
ekrispin commentedThe 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).
Comment #23
BioALIEN commentedSorry 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 specifyI 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.
Comment #24
damien tournoud commented5.x and 6.x are not open to feature request. For Drupal 7 onward, the profile module is obsolete. Won't fix.
Comment #25
pauln600 commentedI 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.
Comment #26
anrikun commented@pauln600: I agree with you.
Here is a patch that fixes this issue.
Comment #28
anrikun commented"needs review" triggers a simpletest on patch from #16.
Strange...
Let's use "active" then...
Comment #29
deepsoulstarfish commentedSubscribe: 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).
Comment #30
chinita7 commentedI applied this patch to core profile module and it works on my site.