示例#1
0
 /**
  * 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
0
 /**
  * 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;
 }
 /**
  * {@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());
 }