@@ -242,9 +242,18 @@ public function runDBChecks(bool $required, string $field, $value, array $db_che
242
242
//if there is no query, set the field key and the params key
243
243
if (!array_key_exists ('query ' , $ db_check ))
244
244
{
245
- $ db_check ['field ' ] = Util::value ('field ' , $ db_check , is_int ($ value )? 'id ' : $ field ); //defaults to id
246
- $ db_check ['params ' ] = Util::arrayValue ('params ' , $ db_check , [$ value ]); //defaults to value
245
+ $ db_check ['field ' ] = Util::value (
246
+ 'field ' ,
247
+ $ db_check ,
248
+ is_int ($ value )? 'id ' : $ this ->resolveModelFieldName ($ field )
249
+ );
250
+ $ db_check ['params ' ] = Util::arrayValue (
251
+ 'params ' ,
252
+ $ db_check ,
253
+ [$ value ]
254
+ );
247
255
}
256
+ $ db_check ['params ' ] = Util::arrayValue ('params ' , $ db_check );
248
257
249
258
$ check_if = $ db_check ['if ' ];
250
259
$ method = Util::value ($ check_if , $ this ->getDBChecksMethodMap (), 'null ' );
@@ -674,17 +683,17 @@ protected function processRules()
674
683
675
684
$ this ->_rule_options [$ field ]['type ' ] = $ this ->_filters [$ field ]['type ' ] = $ type ;
676
685
677
- $ require_if = Util::arrayValue (' requireIf ' , $ rule , []);
678
- $ condition = Util::value ('condition ' , $ require_if , '' );
686
+ $ required_if = Util::arrayValue ([ ' requiredIf ' , ' requireIf '] , $ rule , []);
687
+ $ condition = Util::value ('condition ' , $ required_if , '' );
679
688
680
689
if ($ condition !== '' )
681
690
{
682
691
$ required = false ;
683
692
684
- $ _field = Util::value ('field ' , $ require_if , '' );
693
+ $ _field = Util::value ('field ' , $ required_if , '' );
685
694
$ _field_value = Util::value ($ _field , $ this ->_source );
686
695
687
- $ _value = Util::value ('value ' , $ require_if , '' );
696
+ $ _value = Util::value ('value ' , $ required_if , '' );
688
697
689
698
//checkbox and radio inputs are only set if they are checked
690
699
switch (strtolower ($ condition ))
@@ -713,7 +722,7 @@ protected function processRules()
713
722
}
714
723
$ rule ['required ' ] = $ required ;
715
724
}
716
- Util::unsetFromArray (' requireIf ' , $ rule );
725
+ Util::unsetFromArray ([ ' requiredIf ' , ' requireIf '] , $ rule );
717
726
718
727
//boolean fields are optional by default
719
728
if (Util::keyNotSetOrTrue ('required ' , $ rule ) && $ type !== 'bool ' )
0 commit comments