Change CHtml error CSS classes globally.

Hi,

What is the best place to customize for all views the CHtml static variables for displaying errors: errorSummaryCss, errorCss, errorMessageCss.

I’m using beforeAction in my base Controller class.




<?php

class Controller extends CController

{

    public function beforeAction($action)

    {

        CHtml::$errorCss = '';

        CHtml::$errorSummaryCss = 'error';

        

        return true;

    }

}



Hello, why dont you play around with the css file itself?

I’m using Blueprint CSS framework. They already have a nice set of CSS classes for forms. I want to change CHtml::errorSummaryCss to “.error” and no style for CHtml::errorCss. I don’t want to copy paste the code in all my views.

Blueprint Forms Tests

okey, no issue.

if the css class and id are the same name as that of the Yii then edit the main.php file in the layout folder of the view(by including your css file in the header while deleting the default for the "FORM" css)

:rolleyes:

another option would be to extend the CHtml class

e.g.




class MyHtml extends CHtml

{

   public static $errorCss = '';

   public static $errorSummaryCss = 'error';

}

then use MyHtml::method() rather than CHtml::method()

ok but then how can I make all my controllers use MyHtml instead of CHtml? The errorSummary method uses CHtml by default