First of all I want to mention I've looked into http://drupal.org/node/1516274. This issue doesn't seem to be related to mine though.

But with the latest development version I get flooded with undefined index errors whenever I try to save a content type that has a hierarchical select field:

Like twenty of _clientside_validation_set_title() more or sow ..........................................

  • Notice: Undefined index: error in _clientside_validation_set_title() (regel 413 van /mnt/hgfs/www/mysite/www/sites/all/modules/contrib/clientside_validation/clientside_validation.module).
  • Notice: Undefined index: include_hidden in _clientside_validation_add_general_settings() (regel 335 van /mnt/hgfs/www/mysite/www/sites/all/modules/contrib/clientside_validation/clientside_validation.module).
  • Notice: Undefined index: include_hidden in _clientside_validation_add_general_settings() (regel 340 van /mnt/hgfs/www/mysite/www/sites/all/modules/contrib/clientside_validation/clientside_validation.module).
  • Notice: Undefined index: error_placement in _clientside_validation_add_general_settings() (regel 344 van /mnt/hgfs/www/mysite/www/sites/all/modules/contrib/clientside_validation/clientside_validation.module).
  • Notice: Undefined index: error_placement in _clientside_validation_add_general_settings() (regel 345 van /mnt/hgfs/www/mysite/www/sites/all/modules/contrib/clientside_validation/clientside_validation.module).
  • Notice: Undefined index: include_hidden in _clientside_validation_add_general_settings() (regel 369 van /mnt/hgfs/www/mysite/www/sites/all/modules/contrib/clientside_validation/clientside_validation.module).
  • Notice: Undefined index: error in _clientside_validation_add_general_settings() (regel 370 van /mnt/hgfs/www/mysite/www/sites/all/modules/contrib/clientside_validation/clientside_validation.module).
  • Notice: Undefined index: error in _clientside_validation_add_general_settings() (regel 371 van /mnt/hgfs/www/mysite/www/sites/all/modules/contrib/clientside_validation/clientside_validation.module).
  • Notice: Undefined index: validate_options in _clientside_validation_add_general_settings() (regel 373 van /mnt/hgfs/www/mysite/www/sites/all/modules/contrib/clientside_validation/clientside_validation.module).
  • Notice: Undefined index: validate_options in _clientside_validation_add_general_settings() (regel 374 van /mnt/hgfs/www/mysite/www/sites/all/modules/contrib/clientside_validation/clientside_validation.module).
  • Notice: Undefined index: validate_options in _clientside_validation_add_general_settings() (regel 375 van /mnt/hgfs/www/mysite/www/sites/all/modules/contrib/clientside_validation/clientside_validation.module).
  • Notice: Undefined index: validate_options in _clientside_validation_add_general_settings() (regel 376 van /mnt/hgfs/www/mysite/www/sites/all/modules/contrib/clientside_validation/clientside_validation.module).
  • Notice: Undefined index: validate_options in _clientside_validation_add_general_settings() (regel 377 van /mnt/hgfs/www/mysite/www/sites/all/modules/contrib/clientside_validation/clientside_validation.module).
  • Notice: Undefined index: error in _clientside_validation_add_general_settings() (regel 378 van /mnt/hgfs/www/mysite/www/sites/all/modules/contrib/clientside_validation/clientside_validation.module).

After some research I came to the conclusion that somehow the settings for the form couldn't be loaded. But I'm unable to figure out why and how this function is handling it like that:

function clientside_validation_settings_current_form($settings = NULL) {
  $current = &drupal_static(__FUNCTION__, array());
  if (isset($settings)) {
    $current = $settings;
    if (isset($current['settings']) && is_array($current['settings'])) {
      $current = $current['settings'];
    }
  }
  return $current;
}

This sometimes returns an empty array which I think results in trowing the undefined errors whenever a hierarchical select field is present. Until here I'm at a dead end because I really can't grasp the way the settings are set each time...

Any help is appreciated.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alexverb’s picture

Setting the default settings in drupal_static instead of an empty array does seem to fix this problem.

attiks’s picture

Your diagnose is right, the errors are coming from an empty array, but it shouldn't be empty since it's set inside clientside_validation_form_alter.

Can you debug this a bit further:
1/ Can you check the settings at admin/config/validation/clientside_validation/default, save them and try again
2/ if it still doesn't work add "dpm($definedsettings)" (you'll need the devel module) after lines 206 and 209 inside clientside_validation.module and try again. Let me know which got called and the output.

Cheers

attiks’s picture

Forget to ask, did you run update.php after installing the latest version?

alexverb’s picture

I did run updb and got the new table for the settings. But when saving the defaults the table stays empty correct? Also when saving the defaults I got several notices like these:

  • Notice: Undefined index: disable_html5 in /mnt/hgfs/www/mysite/www/sites/all/modules/contrib/clientside_validation/clientside_validation.module on line 372

After enabling the Clientside Validation HTML5 module this notice was solved. Probably has nothing to do with this issue... Just thought I would mention it.

So after this I went back to the debugger. When loading the form I go past line 206 and get the settings for my node form as expected. Clientside validation is working properly on my node form. But when submitting I seem to go through the same motion of passing without ever passing by line 206.

I have a sneaky suspicion ajax callbacks are messing up the loading of the settings. Because when switching the widget type from HS to select and back (also works by ajax) I get the following tantrum:

Er is een AJAX HTTP fout opgetreden.
HTTP-resultaatcode: 200
Debug informatie volgt.
Pad: /nl/system/ajax
Statustekst: OK
Antwoordtekst:
( ! ) Notice: Undefined index: error in /mnt/hgfs/www/mysite/www/sites/all/modules/contrib/clientside_validation/clientside_validation.module on line 415
Call Stack
#TimeMemoryFunctionLocation
10.0031367820{main}( )../index.php:0
21.156647048176menu_execute_active_handler( ???, ??? )../index.php:21
31.156747048620call_user_func_array
( ???, ??? )../menu.inc:516
41.156747048752ajax_form_callback( )../menu.inc:0
51.167147631104drupal_process_form( ???, ???, ??? )../ajax.inc:370
61.167147632768form_builder( ???, ???, ??? )../form.inc:839
71.182348008348clientside_validation_form_after_build( ???, ??? )../form.inc:1844
81.182348008412drupal_alter( ???, ???, ???, ??? )../clientside_validation.module:314
91.183948010060clientside_validation_form_clientside_validation_form_alter( ???, ???, ??? )../module.inc:1022
101.184048010060clientside_validation_form_after_build_recurse( ???, ???, ???, ??? )../clientside_validation_form.module:8
111.184048011892clientside_validation_form_after_build_recurse( ???, ???, ???, ??? )../clientside_validation_form.module:25
121.184148016228clientside_validation_regular( ???, ???, ???, ??? )../clientside_validation_form.module:19
131.184148016300_clientside_validation_set_required( ???, ???, ???, ???, ??? )../clientside_validation_form.module:134
141.184148016300_clientside_validation_set_title( ??? )../clientside_validation.module:388
( ! ) Notice: Undefined index: error in /mnt/hgfs/www/mysite/www/sites/all/modules/contrib/clientside_validation/clientside_validation.module on line 415
........
........
........ bunch of the same

I think ajax_form_callback() may not pass 206 and 209 but still puts the #after_build function on? Which somehow results in an empty array...

Anywayz, I'm curious what you're thoughts are on this. I've done enough debugging for one evening.

attiks’s picture

Assigned: Unassigned » Jelle_S

@Alex, thanks for the debugging.

But when saving the defaults the table stays empty correct? Yes

And yes AJAX still knows about the #after_build functions, I was afraid this could be a problem while implementing the settings, we'll need to find a proper way to attach the settings to the form without using a global function.

Jelle_S’s picture

Status: Active » Fixed

fixed in the latest dev version

alexverb’s picture

Priority: Major » Normal
Status: Fixed » Active

I don't know if I should open a new issue for this but the update in dev causes a new undefined index error on my hierarchical selects:

Notice: Undefined index: field_editorial_domains[nl][hierarchical_select][selects][0] in /mnt/hgfs/www/mysite/sites/all/modules/contrib/clientside_validation/clientside_validation_form/clientside_validation_form.module on line 166

Seems like the new check on a hierarchical select is the culprit. It also destroys the ajax callback of HS. I don't really understand why there should be a "required" validation on it when my hierarchical selects aren't required.

alexverb’s picture

When I make the field required, the undefined index error is gone. So I guess a simple check would suffise. See patch. Or does _clientside_validation_set_blacklist() do something with that message?

alexverb’s picture

Status: Active » Needs review

Forgot to change status.

attiks’s picture

Status: Needs review » Needs work

Patch applied to latest dev. The required is set if enforce_deepest is set, but I'll have to talk to Jelle_S to see if this is the right approach.

Jelle_S’s picture

Status: Needs work » Fixed

Required is set on the first dropdown of hierarchical select if the element is required.

Then, if enforce_deepest is set, required is set on all dropdowns of that hierarchical select. Fixed in latest dev.

ak’s picture

Status: Fixed » Active

I tried using the current dev version and I get following php error with my hierarchical select taxonomy field:
(Notice: Undefined index: field_country[und] in clientside_validation_regular() (line 172 of … /clientside_validation_form.module))

attiks’s picture

Assigned: Jelle_S » Unassigned
Status: Active » Fixed

Fixed in latest dev, there was a typo, can you check if it's working?

ak’s picture

The PHP Error has gone away.
But, the clientside validation doesn't seem to work. My hs-box doesn't show any errors.

attiks’s picture

Assigned: Unassigned » Jelle_S
Status: Fixed » Active
Jelle_S’s picture

Can you post a screenshot of your field settings and of the HS settings?

ak’s picture

Hi there, I previosly had this field set to "Exclude from clientside validation" because of the PHP Error. However, switching this setting off again has no effect.
I can see the field listed in Drupal.settings array though:

"field_country[und][hierarchical_select][selects][0]":{
"required":true,"messages":{"required":"\u0022Country\u0022 field is required.","blacklist":"\u0022Country\u0022 field is required."},
"blacklist":["label_0"]},
"field_country[und]":{"required":true,"messages":{"required":"\u0022Country\u0022 field is required."}},

My clientside validation error placement is set to display "before input". I temporary switched this to "top of form" to duble check this is not an issue, but theres no error message displayed in either way. See Screenshots of my field settings attached.

Jelle_S’s picture

Status: Active » Fixed

ok, fixed in latest dev. The problem was that the select html value is different when you define your own label in the settings, or when you don't define a label

Jelle_S’s picture

Assigned: Jelle_S » Unassigned

Status: Fixed » Closed (fixed)

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