Validation function for profile fields (profile_validate_profile function in profile.module) is NOT invoked upon completion of registration (it is invoked only when editing profile fields).

Some other basic validation functionality is being executed in the case of registration. I couldn't find it (I disabled all relevant contributed modules such as logintoboggan etc. and it still persists)

You can easily identify it by the different error messages issued when a required field is not filled:

profile_validate_profile function in profile.module line 736 issues the following message: "The field blabla is required" (that is indeed issued when editing profile fields and not filling a requied field)

BUT the messages issued in such a case during registration is "blabla field is required"

This problem prevents me from adding validation rules to the registration process.

Comments

scoutbaker’s picture

Status: Active » Postponed (maintainer needs more info)

I have been unable to reproduce this using a fresh install of d5.1 and d5.5. In both cases, I enabled the Profile module. The only other modules installed and enabled are the defaults.

I then added a single-line textfield. I selected "User must enter a value" and "Visible in user registration form". The visibility setting was left at the default.

The tests performed were:

  • Register a new user - leave the field blank
  • Add a user as userid 1 - leave the field blank
  • Edit the userid 1 profile - leave the field blank and submit
  • Create a user (with a valid entry for the field), then edit the profile as userid 1 and delete the value
  • Create a user (with a valid entry for the field), then edit the profile as the user and delete the value

In every instance, the resulting message was, "blabla field is required". The profile_validate_profile function was never called.

@ekrispin - What modules did you have installed/enabled? And was there a particular field type you were using when profile_validate_profile was called?

ekrispin’s picture

The other relevant module is logintoboggan.

We have the issue with multi-select fields (e.g. country, gender) in which we want to validate that the user has selected something (rather leaving the default "--" value for the field).

We implemented this validation for multi-select fields in the profile_validate_profile function in profile.module but as stated above, while it is invoked when editing the profile (and so our validation works in this case), it is not invoked during registration and so our validation during registration is not activated.

ekrispin’s picture

I suspect http://drupal.org/node/223845#comment-763846 is related to this issue (see the second comment there)

ekrispin’s picture

OK, finally solved it:

In case of registration, form validation is done by form.inc (/includes/form.inc)
In case of profile edit, form validation is done by profile_validate_profile function in profile.module

We added our special validation for multi-select fields also to forms.inc and now it works

Alaska’s picture

Would it be possible to post the code you used to solve the issue? Trying to add a phone filed to the profile module. The field displays, but will not validate. Using 5.14 so the fix should work.

Thanks

dpearcefl’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

Considering the lack of activity on this issue and that Drupal v5 is no longer supported by for fixes or patches, I am going to close this ticket.