My users must select from their dropdowns : Location + Ethnicity
I have two types of dropdowns: one is "The user must enter a value" and one he must NOT.
There is a small bug regarding the first option displayed within the dropdowns.

Both dropdowns have the SAME options content (countries of the world)

But in dropdown 1 i get the first country as an entry, on the other dropdown "--"
Please see screenshot for explanation

Any advice how to fix that?

And another quick question: i supose that the idea was that the first entry is "--" so if user does not select any option, he will get a error ... is that right?

CommentFileSizeAuthor
profile_checkboxes_issue.jpg7.58 KBsh2gr

Comments

johnhanley’s picture

Component: Miscellaneous » User interface
Category: bug » support
Priority: Normal » Minor
Status: Active » Closed (fixed)

This has nothing to do with Profile Checkboxes since dropdowns (aka. list selections) are provided by the core profile module. Also, what you describe it expected behavior and is not a bug.

With that in mind the answer to your question is that dropdown 1 is required (noted by the asterisk) and dropdown 2 is optional (noted by the inclusion of the default option "--"). Only required elements will fail validation. You can change the required/optional selection on the corresponding profile field edit page.

sh2gr’s picture

Hello,

thanks for your help.
Sorry, i am very new to Drupal and some functions are new to me as well.

However, i do not understand the logic.

As mentioned: I have one "required" and one "non required" list selection.
On my screenshot you see the first value to be "Aaland Islands". Now, supose that the user forgets to pick his Location, skips that part -> then i will (propably) have a lot of users with location "Aaland Islands".
How does the system validate that the user forgot to choose his location...when the first option passed is a "acceptable value"?

On the other side, the "non required" list selection has a "--" value, where i thought that a Drupal function does recognize this value as a "failing entry".

I mean, how is validation done when (there where validation is needed) already a acceptable value exists?
Because non of my tests showed any validation remarks.

johnhanley’s picture

So what you're asking is how to force the user to make a dropdown selection instead of simply accepting the default first option value? The answer is you can't, not by default. Required excludes a default (unselected) option and optional does. You would have to prepend a "--" option (with a empty string "" value) at the beginning of the option array. This could be accomplished by using the PHP function array_unshift() via the hook_alter_form(). See the Drupal API for more detail.

sh2gr’s picture

Thank you a lot for this.
(scratches his head)... don't understand how a "set required" option has not been made to include a lookup... instead a non required has the "--" empty string.

Thank you again for this