1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-07-02 22:45:02 +03:00

доработка конвертации валидатора

This commit is contained in:
Mzhelskiy Maxim 2013-08-20 17:37:44 +07:00
parent c5d539f92c
commit 82242d2403

View file

@ -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" ';
}
}
}