在规则中,我有一个带有html文本的自定义消息:
[ 'user_email', 'required', 'message' => 'Don\'t have one? <a href="/contact-us">Give us a call</a>' ],
我的表格:
<?php $form = ActiveForm::begin( [
'enableAjaxValidation' => true,
'validationUrl' => '/user/validate-register',
] ); ?>
<?= $form->field( $model, 'user_email', [
'errorOptions' => [
'encode' => false,
]
] )->textInput( [ 'maxlength' => true ] ) ?>
当我输入errorOptions时,不会显示错误消息...它突出显示为红色,但不显示内联消息。
使用errorOptions
时,不会显示任何错误消息
答案 0 :(得分:6)
添加课程help-block
以正确应用css。
<强>表格强>
$form = ActiveForm::begin([
'fieldConfig' => [
'errorOptions' => [
'encode' => false,
'class' => 'help-block'
],
],
]);
字段强>
<?= $form->field( $model, 'user_email', [
'errorOptions' => [
'encode' => false,
'class' => 'help-block'
]
])->textInput( [ 'maxlength' => true ] ) ?>