function validate($value, $alldata)
 {
     $rows = $this->mParams['rows'];
     $columns = $this->mParams['columns'];
     // Make sure user-defined validation callback is run
     $p = parent::validate($value, $alldata);
     if ($p !== true) {
         return $p;
     }
     // Make sure submitted value is an array
     if (!is_array($value)) {
         return false;
     }
     // If all options are valid, array_intersect of the valid options
     // and the provided options will return the provided options.
     $validOptions = [];
     foreach ($rows as $rowTag) {
         foreach ($columns as $columnTag) {
             $validOptions[] = $columnTag . '-' . $rowTag;
         }
     }
     $validValues = array_intersect($value, $validOptions);
     if (count($validValues) == count($value)) {
         return true;
     } else {
         return $this->msg('htmlform-select-badoption')->parse();
     }
 }
 function validate($value, $alldata)
 {
     $p = parent::validate($value, $alldata);
     if ($p !== true) {
         return $p;
     }
     $validOptions = HTMLFormField::flattenOptions($this->getOptions());
     if (in_array(strval($value), $validOptions, true)) {
         return true;
     } else {
         return $this->msg('htmlform-select-badoption')->parse();
     }
 }
 function validate($value, $alldata)
 {
     $p = parent::validate($value, $alldata);
     if ($p !== true) {
         return $p;
     }
     if (!is_array($value)) {
         return false;
     }
     # If all options are valid, array_intersect of the valid options
     # and the provided options will return the provided options.
     $validOptions = HTMLFormField::flattenOptions($this->getOptions());
     $validValues = array_intersect($value, $validOptions);
     if (count($validValues) == count($value)) {
         return true;
     } else {
         return $this->msg('htmlform-select-badoption')->parse();
     }
 }
 protected function validate(HTMLFormField $field, $submitted)
 {
     return $field->validate($submitted, [self::$defaultOptions['fieldname'] => $submitted]);
 }
Beispiel #5
0
 function validate($value, $alldata)
 {
     $p = parent::validate($value, $alldata);
     if ($p !== true) {
         return $p;
     }
     if (!is_string($value) && !is_int($value)) {
         return false;
     }
     $validOptions = HTMLFormField::flattenOptions($this->mParams['options']);
     if (in_array($value, $validOptions)) {
         return true;
     } else {
         return $this->msg('htmlform-select-badoption')->parse();
     }
 }
 /**
  * HTMLMultiSelectField throws validation errors if we get input data
  * that doesn't match the data set in the form setup. This causes
  * problems if something gets removed from the watchlist while the
  * form is open (bug 32126), but we know that invalid items will
  * be harmless so we can override it here.
  *
  * @param $value String the value the field was submitted with
  * @param $alldata Array the data collected from the form
  * @return Mixed Bool true on success, or String error to display.
  */
 function validate($value, $alldata)
 {
     // Need to call into grandparent to be a good citizen. :)
     return HTMLFormField::validate($value, $alldata);
 }
 public function validate($values, $alldata)
 {
     if (isset($this->mParams['required']) && $this->mParams['required'] !== false && !$values) {
         return $this->msg('htmlform-cloner-required')->parseAsBlock();
     }
     if (isset($values['nonjs'])) {
         // The submission was a non-JS create/delete click, so fail
         // validation in case cancelSubmit() somehow didn't already handle
         // it.
         return false;
     }
     foreach ($values as $key => $value) {
         $fields = $this->createFieldsForKey($key);
         foreach ($fields as $fieldname => $field) {
             if (!array_key_exists($fieldname, $value)) {
                 continue;
             }
             $ok = $field->validate($value[$fieldname], $alldata);
             if ($ok !== true) {
                 return false;
             }
         }
     }
     return parent::validate($values, $alldata);
 }