mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-07-02 22:45:02 +03:00
доработка конвертации валидатора
This commit is contained in:
parent
c5d539f92c
commit
82242d2403
|
@ -47,11 +47,40 @@ function smarty_function_field_make_rule($params, &$smarty) {
|
|||
* Конвертация строкового валидатора
|
||||
*/
|
||||
if ($sType=='string') {
|
||||
$aResult[]='rangelength="['.$oValidator->min.','.$oValidator->max.']" ';
|
||||
if (!$oValidator->allowEmpty) {
|
||||
$aResult[]='required="true" ';
|
||||
if (!is_null($oValidator->min) and !is_null($oValidator->max)) {
|
||||
$aResult[]='rangelength="['.$oValidator->min.','.$oValidator->max.']" ';
|
||||
} elseif (!is_null($oValidator->min)) {
|
||||
$aResult[]='minlength="'.$oValidator->min.'" ';
|
||||
} else {
|
||||
$aResult[]='maxlength="'.$oValidator->max.'" ';
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Конвертация числового валидатора
|
||||
*/
|
||||
if ($sType=='number') {
|
||||
if ($oValidator->integerOnly) {
|
||||
$aResult[]='type="digits" ';
|
||||
} else {
|
||||
$aResult[]='type="number" ';
|
||||
}
|
||||
if (!is_null($oValidator->max)) {
|
||||
$aResult[]='max="'.$oValidator->max.'" ';
|
||||
}
|
||||
if (!is_null($oValidator->min)) {
|
||||
$aResult[]='min="'.$oValidator->min.'" ';
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Конвертация почтового валидатора
|
||||
*/
|
||||
if ($sType=='email') {
|
||||
$aResult[]='type="email" ';
|
||||
}
|
||||
|
||||
if (!$oValidator->allowEmpty) {
|
||||
$aResult[]='required="true" ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue