|
|
@ -1271,6 +1271,8 @@ class BaseHtml |
|
|
|
* - tag: this specifies the tag name. If not set, "div" will be used. |
|
|
|
* - tag: this specifies the tag name. If not set, "div" will be used. |
|
|
|
* See also [[tag()]]. |
|
|
|
* See also [[tag()]]. |
|
|
|
* - encode: boolean, if set to false then the error message won't be encoded. |
|
|
|
* - encode: boolean, if set to false then the error message won't be encoded. |
|
|
|
|
|
|
|
* - errorMethod (since 2.0.14): string, if set then this value will be used as a method name to |
|
|
|
|
|
|
|
* be called instead of getFirstError(). |
|
|
|
* |
|
|
|
* |
|
|
|
* See [[renderTagAttributes()]] for details on how attributes are being rendered. |
|
|
|
* See [[renderTagAttributes()]] for details on how attributes are being rendered. |
|
|
|
* |
|
|
|
* |
|
|
@ -1279,7 +1281,8 @@ class BaseHtml |
|
|
|
public static function error($model, $attribute, $options = []) |
|
|
|
public static function error($model, $attribute, $options = []) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$attribute = static::getAttributeName($attribute); |
|
|
|
$attribute = static::getAttributeName($attribute); |
|
|
|
$error = $model->getFirstError($attribute); |
|
|
|
$errorMethod = ArrayHelper::remove($options, 'errorMethod', 'getFirstError'); |
|
|
|
|
|
|
|
$error = $model->$errorMethod($attribute); |
|
|
|
$tag = ArrayHelper::remove($options, 'tag', 'div'); |
|
|
|
$tag = ArrayHelper::remove($options, 'tag', 'div'); |
|
|
|
$encode = ArrayHelper::remove($options, 'encode', true); |
|
|
|
$encode = ArrayHelper::remove($options, 'encode', true); |
|
|
|
return Html::tag($tag, $encode ? Html::encode($error) : $error, $options); |
|
|
|
return Html::tag($tag, $encode ? Html::encode($error) : $error, $options); |
|
|
|