/** * Get the value to validate from either the global request variable or the cached __validvalues array. * * @internal * @param integer $intDynamicPosition Using the intDynamicPosition parameter, you can get the specific value * of a dynamic field. * @return string|array|null Returns the submitted field value. If no sumitted value is set, * return value is the cached valid value. If no cached value is set, return value is the default value. If no * default value is set, return value is null. When field type is `ValidForm::VFORM_FILE` and a file is submitted, * the return value is the `$_FILES[fieldname]` array. */ public function getValue($intDynamicPosition = 0) { $varReturn = null; if (isset($this->__overrideerrors[$intDynamicPosition]) && empty($this->__overrideerrors[$intDynamicPosition])) { $varReturn = null; } else { $strFieldName = $intDynamicPosition > 0 ? $this->__fieldname . "_" . $intDynamicPosition : $this->__fieldname; //if ($this->__type !== ValidForm::VFORM_FILE) { // Default value $varValidValue = $this->__field->getDefault(); // Get cached value if set if (isset($this->__validvalues[$intDynamicPosition])) { $varValidValue = $this->__validvalues[$intDynamicPosition]; } // Overwrite cached value with value from REQUEST array if available if (ValidForm::getIsSet($strFieldName)) { $varValue = ValidForm::get($strFieldName); if (is_array($varValue)) { $varReturn = []; foreach ($varValue as $key => $value) { $varReturn[$key] = $value; // NEVER return unsanitized output } } else { $varReturn = $varValue; // NEVER return unsanitized output } } else { $varReturn = $varValidValue; } //} // *** Not ready for implementation yet. // else { // if (isset($_FILES[$strFieldName]) && isset($_FILES[$strFieldName])) { // $varReturn = $_FILES[$strFieldName]; // } // } } return $varReturn; }