how can i add class to errorsummay without remove

2019-09-18 06:48发布

I'm trying to add a css class to the errorSummary() in yii framwork but after add class i have not header error default
how can i add class to errorsummay without remove header message

<?php echo  $form->errorSummary($model, '', '', array('class' => 'alert alert-error')); ?>

标签: css forms yii
3条回答
SAY GOODBYE
2楼-- · 2019-09-18 07:12

you can set attribute errorMessageCssClass of class CActiveForm want:

and also errorSummary() has htmlOptions !

  public string errorSummary(mixed $models, string $header=NULL, string $footer=NULL, array $htmlOptions=array ( ))
查看更多
smile是对你的礼貌
3楼-- · 2019-09-18 07:33

Its a very simple one,

you can pass the class you need this way,

<?php echo CHtml::errorSummary($model, null, null, array('class'=>'className')); ?>

or

<?php echo  $form->errorSummary($model, null, null, array('class'=>'className')); ?>

so this will allow you add the class while you have the header.

check here for more information : http://www.yiiframework.com/doc/api/1.1/CActiveForm#errorSummary-detail

since you are passing, empty string for header it causes the header issue. default value is null for $header.

public string errorSummary(mixed $models, string $header=NULL, string $footer=NULL, array $htmlOptions=array ( ))
查看更多
ら.Afraid
4楼-- · 2019-09-18 07:37

Adjust code like this.

echo $form->errorSummary($model,NULL,NULL,array('class'=>'alert alert-error'));
查看更多
登录 后发表回答