diff --git a/libraries/config/FormDisplay.php b/libraries/config/FormDisplay.php index ab02fa1f70..aeff097624 100644 --- a/libraries/config/FormDisplay.php +++ b/libraries/config/FormDisplay.php @@ -639,12 +639,12 @@ class FormDisplay // cast variables to correct type switch ($type) { case 'double': - settype($_POST[$key], 'float'); + settype($this->_trimString($_POST[$key]), 'float'); break; case 'boolean': case 'integer': if ($_POST[$key] !== '') { - settype($_POST[$key], $type); + settype($this->_trimString($_POST[$key]), $type); } break; case 'select': @@ -660,7 +660,7 @@ class FormDisplay break; case 'string': case 'short_string': - $_POST[$key] = trim($_POST[$key]); + $_POST[$key] = $this->_trimString($_POST[$key]); break; case 'array': // eliminate empty values and ensure we have an array @@ -876,10 +876,25 @@ class FormDisplay private function _fillPostArrayParameters($post_values, $key) { foreach ($post_values as $v) { - $v = trim($v); + $v = $this->_trimString($v); if ($v !== '') { $_POST[$key][] = $v; } } } + + /* + * Converts given (request) paramter to string + * + * @param mixed $value Value to convert + * + * @return string + */ + private function _trimString($value) + { + while (is_array($value)) { + $value = reset($value); + } + return trim((string)$value); + } }