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
Comment #1
scoutbaker commentedI 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:
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?
Comment #2
ekrispin commentedThe 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.
Comment #3
ekrispin commentedI suspect http://drupal.org/node/223845#comment-763846 is related to this issue (see the second comment there)
Comment #4
ekrispin commentedOK, 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
Comment #5
Alaska commentedWould 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
Comment #6
dpearcefl commentedConsidering 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.