/** @param fields array array with keys being fields and values being rules to apply to fields. See appyFilterValidateRules for rule syntax self::filterAndValidate( array( 'email' => rules 'loginName' => rules ) ); @return false if error in any context, else true */ function filterAndValidate($fields, $options = null) { if ($options['filterArrays'] || !isset($options['filterArrays'])) { foreach ($fields as $field => $rules) { if (is_array($this->in[$field])) { \control\Field::makeString($this->in[$field]); } } } foreach ($fields as $field => $rules) { $continue = $this->applyFilterValidateRules($field, $rules, $options['errorOptions']); if (!$continue) { break; } } return !$this->hasError(); }
/** @param options behavior either a string of one of the Form methods, or a custom callback - for selecting a value (where multiple inputs might be present). allowArray whether to allow the value return to be an array (useful for multi-selects) format callback for formatting the value after it is found */ function resolveValue($name, $value = null, $options = []) { $behavior = $options['behavior'] ? $options['behavior'] : $this->valueBehavior; if (!is_array($behavior)) { $behavior = array($this, $behavior); } $value = call_user_func_array($behavior, array($name, $value)); if (!$options['allowArray']) { \control\Field::makeString($value); } if ($options['format']) { $value = call_user_func_array($options['format'], array($value, $name)); } return $value; }