Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
D
Drupal
  • Project overview
    • Project overview
    • Details
    • Activity
  • Issues 53
    • Issues 53
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Operations
    • Operations
    • Incidents
  • Analytics
    • Analytics
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Create a new issue
  • Issue Boards
  • Development
  • Drupal
  • Issues
  • #62

Closed
Open
Opened May 17, 2019 by VangelisP@VangelisP

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).

Searching a little bit more, I have noticed on line 681 that there's an arg() comparison so that Civi can understand what path users are coming from (here)

May I suggest (i can make a MR) instead of doing a path search using the arg() variable, check the form #action or #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 user_account_form_validate function here)

This way, validation is always there, as long as the form #action or #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 .has-error.

To upload designs, you'll need to enable LFS and have admin enable hashed storage. More information
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: dev/drupal#62