Mohit Bhansali
Mohit Bhansali

Reputation: 1785

Any way to change the tag of error() in CActiveForm?

By default, CActiveForm::error() display an error in <div> tag. Sometimes I want to use <span> tag instead of <div>, but it seems that the source code of this method has fixed using div tag only.

In CHtml::error():

return self::tag('div',$htmlOptions,$error);

So is there any method to change the tag without touching the framework's source code?

Upvotes: 0

Views: 652

Answers (1)

katsanva
katsanva

Reputation: 115

Basically CHtml::$errorContainerTag = 'span'; should do the trick.

And you can always override CHtml::error(...) method via child class (e.g. class Html extends CHtml {...})

Upvotes: 2

Related Questions