本文整理匯總了PHP中Zend\InputFilter\InputFilter::setValidationGroup方法的典型用法代碼示例。如果您正苦於以下問題:PHP InputFilter::setValidationGroup方法的具體用法?PHP InputFilter::setValidationGroup怎麽用?PHP InputFilter::setValidationGroup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend\InputFilter\InputFilter
的用法示例。
在下文中一共展示了InputFilter::setValidationGroup方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: setValidationGroup
/**
* Override to implicitly ignore unkown fields
* This allow for user to submit extra fields
* @param mixed $name
* @return mixed
*/
public function setValidationGroup($name)
{
if (is_array($name)) {
$known = array_keys($this->getInputs());
$name = array_intersect($name, $known);
}
return parent::setValidationGroup($name);
}
示例2: setInputsToFilter
/**
* Set inputs (by name) to filter/validate.
*
* null = filter all
* empty array = filter none
*
* @param array|null $inputs
* @return BaseFilter
*/
public function setInputsToFilter($inputs)
{
// No need to apply validation groups for empty arrays
if (!is_array($inputs) || $this->needsFiltering($inputs)) {
try {
if ($inputs === null) {
// Provide Zend's expected value when intending to filter all inputs...
$group = self::VALIDATE_ALL;
} elseif (is_array($inputs)) {
$knownInputs = array_keys($this->getInputs());
$group = array_intersect($inputs, $knownInputs);
} else {
$group = $inputs;
}
parent::setValidationGroup($group);
} catch (InputFilterException $e) {
throw new Exception\InvalidArgumentException(sprintf('Failed to set inputs to filter: %s', $e->getMessage()), 0, $e);
}
}
// Apply only after we made sure the provided inputs are valid
$this->inputsToFilter = $inputs;
return $this;
}
示例3: setValidationGroup
/**
* {@inheritdoc}
*/
public function setValidationGroup($name)
{
if ($name === self::VALIDATE_ALL) {
$this->validationGroup = null;
return $this;
}
if (is_array($name)) {
// Best effort check if the validation group was set by a form for BC
if (count($name) == count($this->collectionData) && is_array(reset($name))) {
return parent::setValidationGroup(reset($name));
}
return parent::setValidationGroup($name);
}
return parent::setValidationGroup(func_get_args());
}