@@ -393,8 +393,11 @@ protected function getDefaultsSourceValues($source = [], $keys = [], $json = fal
393
393
$ value = [$ key => $ value ];
394
394
}
395
395
}
396
- if (is_array ($ value ) && array_keys ($ value ) !== range (0 , count ($ value ) - 1 )) {
397
- $ fields = $ value ;
396
+ if (is_array ($ value )) {
397
+ if (array_keys ($ value ) === range (0 , count ($ value ) - 1 )) {
398
+ $ value = [$ key => $ value ];
399
+ }
400
+ $ fields = array_merge ($ fields , $ value );
398
401
}
399
402
}
400
403
}
@@ -555,6 +558,9 @@ public function renderForm()
555
558
}
556
559
}
557
560
if ($ api ) {
561
+ $ allowed = $ this ->config ->loadArray ($ this ->getCFGDef ('allowedApiFields ' ));
562
+ $ forbidden = $ this ->config ->loadArray ($ this ->getCFGDef ('forbiddenApiFields ' ));
563
+ $ out ['fields ' ] = $ this ->filterFields ($ out ['fields ' ], $ allowed , $ forbidden );
558
564
$ out = $ this ->getCFGDef ('apiFormat ' , 'json ' ) == 'json ' ? jsonHelper::toJson ($ out ) : $ out ;
559
565
}
560
566
@@ -721,19 +727,19 @@ public function validate($validator, array $rules, array $fields)
721
727
$ message = $ description ;
722
728
}
723
729
if (method_exists ($ validator , $ rule )) {
724
- $ result = count ($ params ) == = $ reflection ->getMethod ($ rule )->getNumberOfRequiredParameters () && call_user_func_array (
730
+ $ result = count ($ params ) > = $ reflection ->getMethod ($ rule )->getNumberOfRequiredParameters () && call_user_func_array (
725
731
[$ validator , $ rule ],
726
732
$ params
727
733
);
728
734
} else {
729
735
if (isset ($ description ['function ' ])) {
730
- $ rule = $ description ['function ' ];
731
- if (is_callable ($ rule )) {
732
- $ result = call_user_func_array ($ rule , array_merge ([$ this ], $ params ));
736
+ $ customRule = $ description ['function ' ];
737
+ if (is_callable ($ customRule )) {
738
+ $ result = call_user_func_array ($ customRule , array_merge ([$ this ], $ params ));
733
739
}
734
740
} elseif (isset ($ description ['snippet ' ])) {
735
- $ rule = $ description ['snippet ' ];
736
- $ result = $ this ->modx ->runSnippet ($ rule , [
741
+ $ customRule = $ description ['snippet ' ];
742
+ $ result = $ this ->modx ->runSnippet ($ customRule , [
737
743
'FormLister ' => $ this ,
738
744
'value ' => $ value
739
745
]);
@@ -1326,11 +1332,11 @@ public function redirect($param = 'redirectTo', array $_query = [])
1326
1332
if ($ redirect = $ this ->getCFGDef ($ param , 0 )) {
1327
1333
$ header = '' ;
1328
1334
$ query = http_build_query ($ _query );
1329
- if (is_numeric ($ redirect )) {
1335
+ if (is_numeric ($ redirect ) || filter_var ( $ redirect , FILTER_VALIDATE_URL ) !== false ) {
1330
1336
$ page = $ redirect ;
1331
1337
} else {
1332
1338
$ redirect = $ this ->config ->loadArray ($ redirect , '' );
1333
- if (! is_array ($ redirect) ) {
1339
+ if (filter_var ($ redirect, FILTER_VALIDATE_URL ) !== false ) {
1334
1340
$ page = $ redirect ;
1335
1341
} else {
1336
1342
if (isset ($ redirect ['query ' ]) && is_array ($ redirect ['query ' ])) {
0 commit comments