Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
refactor(quickFormCustom): change error type of applyfilter (#6302)
Browse files Browse the repository at this point in the history
Change fatal error to notice to comply with previous version error type all over the code.
  • Loading branch information
victorvassilev authored May 25, 2018
1 parent 5c755a6 commit 5eead0d
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions www/lib/HTML/QuickForm/HTML_QuickFormCustom.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,42 @@ public function addRule($element, $message, $type, $format=null, $validation='se
);
}


/**
* Applies a data filter for the given field(s)
*
* @param mixed $element Form element name or array of such names
* @param mixed $filter Callback, either function name or array(&$object, 'method')
* @throws HTML_QuickForm_Error
*/
public function applyFilter($element, $filter)
{
if (!is_callable($filter)) {
trigger_error("Callback function '$filter' does not exist");
}
if ($element == '__ALL__') {
$this->_submitValues = $this->_recursiveFilter($filter, $this->_submitValues);
} else {
if (!is_array($element)) {
$element = array($element);
}
foreach ($element as $elName) {
$value = $this->getSubmitValue($elName);
if (null !== $value) {
if (false === strpos($elName, '[')) {
$this->_submitValues[$elName] = $this->_recursiveFilter($filter, $value);
} else {
$idx = "['" . str_replace(
array('\\', '\'', ']', '['), array('\\\\', '\\\'', '', "']['"),
$elName
) . "']";
eval("\$this->_submitValues{$idx} = \$this->_recursiveFilter(\$filter, \$value);");
}
}
}
}
}

/**
* Add additional custom element types to $GLOBALS
*/
Expand Down

0 comments on commit 5eead0d

Please sign in to comment.