public static function validate($checkType, $value) { $blnReturn = FALSE; if (array_key_exists($checkType, self::$checks)) { if (empty(self::$checks[$checkType])) { $blnReturn = TRUE; } else { switch ($checkType) { case VFORM_CAPTCHA: $blnReturn = PhpCaptcha::Validate(ValidForm::get($value)); break; default: $blnReturn = preg_match(self::$checks[$checkType], $value); } } } else { $blnReturn = preg_match($checkType, $value); } return $blnReturn; }
/** * If this is an active area, this will return the value of the checkbox. * @internal * @param string $intCount Dynamic counter, defaults to null * @return boolean */ public function getValue($intCount = null) { $strName = $intCount > 0 ? $this->__name . "_" . $intCount : $this->__name; $value = ValidForm::get($strName); return $this->__active && !empty($value) || !$this->__active ? true : false; }
/** * 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; }
/** * Check if the wizard is submitted * * See {@link \ValidFormBuilder\ValidForm::isSubmitted()} * * @return boolean */ public function isSubmitted($blnForce = false) { $blnReturn = false; if (ValidForm::get("vf__dispatch") == $this->__name) { // *** Try to retrieve the uniqueId from a REQUEST value. $strUniqueId = ValidWizard::get("vf__uniqueid"); if (!empty($strUniqueId)) { $this->__setUniqueId($strUniqueId); } $blnReturn = true; } elseif ($blnForce) { $blnReturn = true; } return $blnReturn; }
/** * Check if the form is submitted by validating the value of the hidden * vf__dispatch field. * * @param boolean $blnForce * Fake isSubmitted to true to force field values. * @return boolean [description] */ public function isSubmitted($blnForce = false) { if (ValidForm::get("vf__dispatch") == $this->__name || $blnForce) { return true; } else { return false; } }
public function isSubmitted() { if (ValidForm::get("vf__dispatch") == $this->__name) { return TRUE; } else { return FALSE; } }
private function __validate() { $value = ValidForm::get($this->__name); $blnReturn = TRUE; if ($this->__active && empty($value)) { //*** Not active; } else { foreach ($this->fields as $field) { if (!$field->isValid()) { $blnReturn = FALSE; break; } } } return $blnReturn; }