本文整理汇总了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();
}
}
示例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();
}
}
示例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();
}
}
示例4: validate
protected function validate(HTMLFormField $field, $submitted)
{
return $field->validate($submitted, [self::$defaultOptions['fieldname'] => $submitted]);
}
示例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();
}
}
示例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);
}
示例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);
}