A mandatory list profile displays the first item in the list and if not selected by the user this first item will be stored.

If the list profile is set as not mandatory then it will be displayed starting with a blank (-) space. If this behavior will be applied to mandatory setting, then this will solve the problem.

In other words, how to force the user to select a country from a list if the list will be already completed with the first item?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mariuss’s picture

Version: 6.3 » 6.5
Priority: Normal » Critical

This is a critical bug as far as I can tell. If you look at the code, when the field is flagged as required the first option in the dropdown is supposed to be "--" and then validation should force you to select something else. See profile_form_profile, around line 395.

None of the above happens though, not sure why. Probably the required field is not set for some reason.

ralessi’s picture

Version: 6.5 » 6.8
Assigned: Unassigned » ralessi
FileSize
551 bytes

I had the same issue. I made a patch to fix it. See attachment.

Robert

Gábor Hojtsy’s picture

Title: A mandatory list profile is in fact not mandatory ! » Add "please select" item to required select list item
Version: 6.8 » 7.x-dev
Category: bug » task
Status: Active » Needs work

If you add "Please choose" as an option either way, we need code which validates you are not selecting this item. The idea behind not adding this item is that you cannot select this and forced to select one item. This is I guess a design decision after all. The current Drupal design for these required fields is to always select one item and not have a "Please select" option.

I'd say this would be a fundamental change in UI approach (but could make a lot of sense), so moving to Drupal 7 as task.

mariuss’s picture

Version: 7.x-dev » 6.8

OK, so the proper label may not be "- Please choose -", it should be "--".

I doubt this was a design decision, based on existing code looks like a plain defect. Could be wrong though.

Please keep Drupal 6 issues in Drupal 6. Even if they are never fixed, at least they are known issues. Other people running into this problem will likely find them and not enter duplicates (and also can benefit from the existing discussion or patches).

Given the existing issue tracking system isn't it better to enter a separate defect for D7? It would be great if the Version field was a multi select list box instead of a drop down. Just wondering.

Damien Tournoud’s picture

Version: 6.8 » 7.x-dev

We never open duplicates for the same issues in different branches.

Gábor Hojtsy’s picture

Issues are first fixed in the latest development version and then backported, so that we ensure that the latest development version does not bring back some of the defects, when it gets released. If you set it back to 6.x, you ensure it will not get fixed anytime soon.

mariuss’s picture

Got it, thanks.

totomobile’s picture

Was this issue ever resolved? If so is there a patch for 6.x ? Thanks

tumblingmug’s picture

Regarding #3: No, see this code line. If you provide an assoc. array with an empty key, this does not validate and could be utilized. So changing only 1 line of core code would let required selection lists behave "as expected" or "as normal".

Thanks.

tomsm’s picture

Thanks. #9 works great!

edit: problem: It breaks the order of translated profile term. The translations are not in sync with the original terms anymore!

bleen’s picture

superscribe

tumblingmug’s picture

What did you apply? The helper module or have you changed the line in profile core?

tomsm’s picture

First I changed the line in the profile core. As a result, the translations were out of sync.

Then I installed the helper module which also had some strange effects on the translations similar to that of the core modification.
But after clearing the cache and refreshing the translations it all seems to work correctly.

I do not know what caused these issues. But so far so good.

PS: I use Drupal 6.14 and Internationalization 6.x-1.2

catch’s picture

Priority: Critical » Normal

This needs to be fixed, but it's not critically broken.

sun’s picture

Assigned: ralessi » Unassigned
Status: Needs work » Needs review
FileSize
952 bytes

The fix for D7.

Status: Needs review » Needs work

The last submitted patch, drupal.profile-select-empty.15.patch, failed testing.

quicksketch’s picture

Status: Needs work » Needs review
catch’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs backport to D6
FileSize
905 bytes

Looks fine for D7.

Also attaching D6 backport.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

less special casing ftw.

committed and pushed to 7.x.

Status: Fixed » Closed (fixed)

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

catch’s picture

Version: 7.x-dev » 6.x-dev
Status: Closed (fixed) » Needs review

Marking needs review for D6.

Status: Needs review » 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.