JsFormValidatorBundle
JsFormValidatorBundle copied to clipboard
Incompatibility with Symfony 2.6
Hi, we updated our project to Symfony 2.6 and this budnle is not working correctly.
fp_js_validator.js:533 Uncaught TypeError: Cannot read property 'indexOf' of undefined
I have the same issue rokerkony. Did you fix the issue?
not yet... our issue is stil in the backlog, so we didn't updated to 2.6 :-( :-1:
+1 Same here
+1
+1
+1, Any progress on this issue?
No progress for now. PR is welcome :)
Constraints property $groups is lazy since Symfony 2.6. Solution of this problem:
Fp\JsFormValidatorBundle\Factory\JsFormValidatorFactory
:
protected function parseConstraints(array $constraints)
{
$result = array();
foreach ($constraints as $item) {
$item->groups; // protect against lazy loading since Symfony 2.6
// Translate messages if need and add to result
foreach ($item as $propName => $propValue) {
if (false !== strpos(strtolower($propName), 'message')) {
$item->{$propName} = $this->translateMessage($propValue);
}
}
if ($item instanceof \Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity) {
$item = new UniqueEntity($item, $this->currentElement->getConfig()->getDataClass());
}
$result[get_class($item)][] = $item;
}
return $result;
}
Or hotfix in JS:
FpJsFormValidator._checkValidationGroups = FpJsFormValidator.checkValidationGroups;
FpJsFormValidator.checkValidationGroups = function (needle, haystack) {
if (typeof haystack === 'undefined') {
haystack = ['Default'];
}
return FpJsFormValidator._checkValidationGroups(needle, haystack);
};
I think this was fixed in a8041fe.
@rokerkony Can you approve it?
It should be fixed in #104 Can you confirm it?