Hi Guys

We came across an odd bug where for some forms the settings.clientsideValidation.forms is not populated with the form ID but settings.clientsideValidation.groups does gets filled.

We have been able to reproduce like this:

  • Print a page with NO FORMS at all.
  • Call a form with ctools modal
  • The ajax call will bring the correct settings array but including settings.clientsideValidation.forms, but the global Drupal.settings.clientsideValidation.forms will not be filled (will be empty)
  • The form will not validate
  • Open a second ctools modal (can be a different one with a different form)
  • Drupal.settings.clientsideValidation.forms will be filled this time, and the form will validate (again, can be a different form the second time)

The trick is that for some reason Drupal.settings.clientsideValidation.forms stays as an empty object the first time, but form then on it will be populated correctly.

In case anyone else is having issues, what we are doing is calling a render(drupal_get_form('_parahablar_fake_form')) for the pages were the modal might show up. That will initialise the Drupal.settings.clientsideValidation.forms and things will work.

Cheers

Comments

Status:Active» Fixed

Category:bug» support
Status:Fixed» Active

Sorry for re-opening, how was it fixed?
Need to know so I can patch or implement or download latest dev version.

Thanks

Fixed in latest dev version, wait another 12 hours before downloading or do a git clone.

Related commits
http://drupalcode.org/project/clientside_validation.git/commit/4bf5b2d
http://drupalcode.org/project/clientside_validation.git/commit/c7e90db

It was fixed by this commit. When assigning an object to a variable in js it is assigned by reference. We delete any forms that are not present in the HTML from this.data.forms, which contained a reference (in stead of a copy) of Drupal.settings.clientsideValidation.forms. That is why the form wasn't present in the Drupal.settings. First time our function gets called the form isn't present yet, second time it is but since we deleted it form this.data it is also deleted from Drupal.settings. This way the rules aren't bound to the form.

Long story short: The commit makes sure we store a copy (not a reference) of Drupal.settings.clientsideValidation in this.data

Status:Active» Fixed

Ah, thanks for the info. Closing.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.