JsFormValidatorBundle icon indicating copy to clipboard operation
JsFormValidatorBundle copied to clipboard

Incompatibility with Symfony 2.6

Open rokerkony opened this issue 10 years ago • 12 comments

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

rokerkony avatar Dec 09 '14 08:12 rokerkony

I have the same issue rokerkony. Did you fix the issue?

latysh avatar Jan 18 '15 22:01 latysh

not yet... our issue is stil in the backlog, so we didn't updated to 2.6 :-( :-1:

rokerkony avatar Jan 19 '15 06:01 rokerkony

+1 Same here

igorpan avatar Feb 01 '15 16:02 igorpan

+1

vgross avatar Feb 17 '15 04:02 vgross

+1

manuelj555 avatar Feb 18 '15 04:02 manuelj555

+1, Any progress on this issue?

ZesInternational avatar Mar 12 '15 12:03 ZesInternational

No progress for now. PR is welcome :)

66Ton99 avatar Mar 12 '15 14:03 66Ton99

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;
}

pk16011990 avatar Apr 02 '15 13:04 pk16011990

Or hotfix in JS:

 FpJsFormValidator._checkValidationGroups = FpJsFormValidator.checkValidationGroups;
 FpJsFormValidator.checkValidationGroups = function (needle, haystack) {
     if (typeof haystack === 'undefined') {
         haystack = ['Default'];
     }
     return FpJsFormValidator._checkValidationGroups(needle, haystack);
 };

pk16011990 avatar Apr 02 '15 13:04 pk16011990

I think this was fixed in a8041fe.

sustmi avatar May 24 '15 06:05 sustmi

@rokerkony Can you approve it?

66Ton99 avatar May 25 '15 08:05 66Ton99

It should be fixed in #104 Can you confirm it?

66Ton99 avatar Mar 29 '16 12:03 66Ton99