How to use callback in the form of fully specified class name with method name for JS validation?

Notice: This thread is very old.
MartyIX
Member | 217
+
0
-

https://github.com/…etteForms.js#L130 – the code on the line sanitizes two colons (::) but it doesn't replace slashes (\). The problem is that javascript function name can't contain slashes so effectively it is not possible to use fully specified class name if the class has a namespace.

Example of the problem:

$form->addText('sum', 'Sum')->addRule('\Validators\GeneralValidators::Sum', 'Sum is not correct', array("field1" => $a, "field2" => $b));

I hope I don't miss something obvious.

Proposed fix:

Add after line https://github.com/…etteForms.js#L130 a new line:

op = op.replace('\\', '');

Thanks for help!

HosipLan
Moderator | 4668
+
0
-

I think you're right. Don't you wanna fork nette, fix it and send pull request ?

HosipLan
Moderator | 4668
+
0
-

Great, thanks.