Possible rework on path checking on function civicrm_user_form_validate for 7.x branch
I have had some issues with a civicrm profile validation (even with the default
Name and Address) when it was being exposed in the drupal user registration page after adding some ajax there.
Problem that appears when you ajaxify the form itself, is that contents are getting replaced. When this happens,
civicrm_user_form_validate doesn't work. Specifically, arg(0) & arg(1) are changing (see below).
May I suggest (i can make a MR) instead of doing a path search using the arg() variable, check the form
#user_category instead, like:
$register = (($form['#action'] == '/user/register' || $form['#action'] == '/admin/people/create') ? TRUE : FALSE);or
$register = (($form['#user_category'] == 'account' || $form['#user_category'] == 'register')) ? TRUE : FALSE);(This is taken from
This way, validation is always there, as long as the form
#user_category keeps the same name(s).
One relatively easy way to reproduce is this:
On a/any environment having Drupal 7.x:
- Download and enable bootstrap as the default theme
- Download and enable bootstrap_login_modal which will add AJAX to the user login and user register form(s). This will also cause the non-validation issue i am referring to.
- Try to register yourself and don't add a first and last name, validation will not kick-in.
Now change the civicrm.module on line 681 with the above and re-try to register yourself. Validations will now work.
There is another issue there but it'm still looking at it: The warning comes back, eg. First name is a required field but the CiviCRM profile fields do not light up, they don't inherit the class