本文整理汇总了PHP中Smarty_Internal_Template::getFieldValidation方法的典型用法代码示例。如果您正苦于以下问题:PHP Smarty_Internal_Template::getFieldValidation方法的具体用法?PHP Smarty_Internal_Template::getFieldValidation怎么用?PHP Smarty_Internal_Template::getFieldValidation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Smarty_Internal_Template
的用法示例。
在下文中一共展示了Smarty_Internal_Template::getFieldValidation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_block_input
/**
* Form field row
*
* @package application.helper.smarty
* @author Integry Systems
*
* @package application.helper.smarty
*/
function smarty_block_input($params, $content, Smarty_Internal_Template $smarty, &$repeat)
{
$formParams = $smarty->_tag_stack[0][1];
if (!$repeat) {
$formHandler = $formParams['handle'];
$isRequired = $formHandler ? $formHandler->isRequired($params['name']) : false;
$fieldType = $smarty->getTemplateVars('last_fieldType');
if ($formHandler && $formHandler->getValidator()) {
$err = $formHandler->getValidator()->getErrorList();
$msg = empty($err[$params['name']]) ? '' : $err[$params['name']];
} else {
$msg = '';
}
if ('checkbox' == $fieldType) {
preg_match('/<input(.*) \\/\\>(.*)\\<label(.*)\\>(.*)\\<\\/label\\>/msU', $content, $matches);
if ($matches) {
$content = '<label ' . $matches[3] . '><input ' . $matches[1] . ' /> ' . $matches[4] . '</label>';
}
}
$name = $params['name'];
$class = !empty($params['class']) ? ' ' . $params['class'] : ' ';
unset($params['name'], $params['class']);
$c = $content;
$content = '<div class="row ' . ($msg ? 'has-error' : '') . ' name_' . $name . ' type_' . $fieldType . ' ' . ($isRequired ? ' required' : '') . $class . '"';
foreach ($params as $n => $param) {
$content .= ' ' . $n . '="' . $param . '"';
}
$content .= '>' . $c;
foreach ($smarty->getFieldValidation($name, $formHandler) as $val) {
$content .= '<div ng-show="isSubmitted && form.' . $name . '.$error.' . substr($val[0], 3) . '" class="text-danger">' . $val[1] . '</div>';
}
if ($msg) {
$content .= '<div class="text-danger">' . $msg . '</div>';
}
$content .= '</div>';
$smarty->assign('last_fieldType', '');
$smarty->assign('input_name', '');
return $content;
} else {
$smarty->assign('last_fieldType', '');
$smarty->assign('input_name', $params['name']);
}
}