Skip to content

Commit 4bc5842

Browse files
committed
Fixing Undefined groups error
In Symfony 2.6 The Constraint Object not have a property $groups by Default
1 parent 4fb5752 commit 4bc5842

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

Resources/public/js/FpJsFormValidator.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ var FpJsFormValidator = new function () {
503503
var errors = [];
504504
var i = constraints.length;
505505
while (i--) {
506-
if (this.checkValidationGroups(groups, constraints[i].groups)) {
506+
if (this.checkValidationGroups(groups, constraints[i])) {
507507
errors = errors.concat(constraints[i].validate(value, owner));
508508
}
509509
}
@@ -516,9 +516,11 @@ var FpJsFormValidator = new function () {
516516
* @param {Array} haystack
517517
* @return {boolean}
518518
*/
519-
this.checkValidationGroups = function (needle, haystack) {
519+
this.checkValidationGroups = function (needle, constraint) {
520520
var result = false;
521521
var i = needle.length;
522+
// For symfony 2.6 Api
523+
var haystack = constraint.groups || ['Default'];
522524
while (i--) {
523525
if (-1 !== haystack.indexOf(needle[i])) {
524526
result = true;

Resources/public/js/fp_js_validator.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ var FpJsFormValidator = new function () {
503503
var errors = [];
504504
var i = constraints.length;
505505
while (i--) {
506-
if (this.checkValidationGroups(groups, constraints[i].groups)) {
506+
if (this.checkValidationGroups(groups, constraints[i])) {
507507
errors = errors.concat(constraints[i].validate(value, owner));
508508
}
509509
}
@@ -516,9 +516,11 @@ var FpJsFormValidator = new function () {
516516
* @param {Array} haystack
517517
* @return {boolean}
518518
*/
519-
this.checkValidationGroups = function (needle, haystack) {
519+
this.checkValidationGroups = function (needle, constraint) {
520520
var result = false;
521521
var i = needle.length;
522+
// For symfony 2.6 Api
523+
var haystack = constraint.groups || ['Default'];
522524
while (i--) {
523525
if (-1 !== haystack.indexOf(needle[i])) {
524526
result = true;

0 commit comments

Comments
 (0)