当前位置: 首页>>代码示例>>PHP>>正文


PHP HTMLFormField::validate方法代码示例

本文整理汇总了PHP中HTMLFormField::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP HTMLFormField::validate方法的具体用法?PHP HTMLFormField::validate怎么用?PHP HTMLFormField::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HTMLFormField的用法示例。


在下文中一共展示了HTMLFormField::validate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: validate

 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();
     }
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:28,代码来源:HTMLCheckMatrix.php

示例2: validate

 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();
     }
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:13,代码来源:HTMLSelectField.php

示例3: validate

 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();
     }
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:19,代码来源:HTMLMultiSelectField.php

示例4: validate

 protected function validate(HTMLFormField $field, $submitted)
 {
     return $field->validate($submitted, [self::$defaultOptions['fieldname'] => $submitted]);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:4,代码来源:HTMLCheckMatrixTest.php

示例5: validate

 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();
     }
 }
开发者ID:h4ck3rm1k3,项目名称:mediawiki,代码行数:16,代码来源:HTMLForm.php

示例6: validate

 /**
  * 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);
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:16,代码来源:SpecialEditWatchlist.php

示例7: validate

 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);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:25,代码来源:HTMLFormFieldCloner.php


注:本文中的HTMLFormField::validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。