Hi,
Been playing with your module and trying to add clientside validation to the user registration form like so:
function customizations_form_alter(&$form, &$form_state, $form_id) {
switch($form_id) {
case 'user_register':
// add clientside validation
$form['mail']['#rules'] = array(
'email'
);
$form['pass']['#rules'] = array(
array(
'rule' => 'regexp[/^[a-zA-Z0-9]{6,}$/]',
'error' => 'test'
)
);
break;
}
But whenever I try adding a regexp rule, no matter what the regex is it throws an error;
warning: json_decode() expects parameter 1 to be string, array given in clientside_validation.module on line 120.
warning: Invalid argument supplied for foreach() in clientside_validation.module on line 123
What am I doing wrong? Or is this a bug?
Cheers,
Bartezz
PS. I've already applied the patch commas_in_regex-1425268-3.patch from the fapi_validation issue queue to solve issues with commas in regexes...
Comments
Comment #1
jelle_sThere was indeed a small bug in the way we handled regex validations. This should be fixed in the latest dev version.
There's also a mistake in your code. The $form['pass'] field is of the type 'password_confirm'. When the form is built it is split up in two seperate fields ('Password' and 'Confirm password'). FAPI Validation rules must be defined on the fields themselves.
So here's the correct code you should use with our latest dev version:
Comment #2
bartezz commentedHi Jelle,
Thanx for your reply will try and post back if dev doesn't solve the issue for me.
Also thanx for your pointer, yet I'm not using password_confirm :) I only use a single password field.
Comment #3
bartezz commentedHi Jelle,
Well the error mentioned above is gone after using dev... but I have a new issue now;
Error given;
I tested the regex and it should be good?
When I
dsm($param);in the _clientside_validation_ajax_call() { function of your module I get this;Is this a bug?
Cheers
Comment #4
bartezz commentedOk found the bug!
In clientside_validation_fapi.module on line #108 it says $params[0] this sould simply be $params as $params is a string and not an array.
With $params[0] only the first character of the string is returned resulting in the error mentioned before. Patch attached!
Cheers
Comment #5
bartezz commentedOk, I think the error in my case is because I'm using jquery update module with jquery version set to 1.7, also read this post;
http://drupal.org/node/1067290#comment-5597442
Cheers
Comment #6
jelle_sShould be fixed in the latest stable version (6.x-1.30)
Comment #7.0
(not verified) commentedExtended with PS