如何在Yii中更改cactiveform,chtml和其他小部件/组件的默认设置

I like to globally change default settings for 'CWidgets' like 'CActiveForm', 'CHtml', etc for use with bootstrap or other css frameworks. For this I am using the 'WidgetFactory' in main.php.

Here is my main.php file

main.php

'widgetFactory'=>array(
'widgets'=>array(

    // <form></form>
    'CActiveForm' => array(

        // the CSS class name for error messages. (CHtml::$errorMessageCss)
        'errorMessageCssClass'=>'errorMessage help-block',

        // Please note: When you enable ajax validation, make sure the corresponding
        // controller action is handling ajax validation correctly.
        // There is a call to performAjaxValidation() commented in generated controller code.
        // See class documentation of CActiveForm for details on this.
        'enableAjaxValidation'=>false,
        'enableClientValidation' => false,

        'htmlOptions'=>array(
        ),
    ),
),
),

This works and both the classes 'errorMessage' and 'help-block' are added to all single error messages in the form when doing

<?php echo $form->error($model,'username'); ?>

would render

<div class="errorMessage help-block" id="Tbltask_username_em_">Username cannot be empty
</div>

'errorMessageCssClass' from 'CActiveForm' is a 'Public Property'.

But now I want to change the 'errorSummary' from 'CActiveForm' which is a 'Public Method'. I want to add the classes 'alert' and 'alert-danger'.

<?php echo $form->errorSummary($model); ?>

which would normally render

<div class="errorSummary" id="tbltask-form_es_">
<ul>
    <li>Username cannot be empty.</li>
</ul>
</div>

How to do this? adding it to 'CActiveForm' in the 'WidgetFactory' does not work

// <form></form>
'CActiveForm' => array(

        // 'Public Property' SUCCESS :) CHtml::$errorMessageCss
        'errorMessageCssClass'=>'errorMessage help-block',

        // 'Public Method' FAIL :( CHtml::errorSummary
        'errorSummary'=>'errorSummary alert alert-danger',
),

Can someone explain to me the difference between 'Public Properties' and 'Public Methods' and how do setup default settings for 'Public Methods'? like the errorSummary from 'CActiveForm'?

I noticed all message come from 'CHtml'. How can you change the default 'CHtml' settings in main.php? adding it to the 'widgetFactory' does not work (or does it?)

It appears that CActiveForm::errorSummary() takes a couple of parameters including htmlOptions. You can put the html attributes in here as key/value pairs.

<?= $form->errorSummary($model, NULL, NULL, ['style' => 'errorSummary alert alert-danger']) ?>

or for older php versions

<?php echo $form->errorSummary($model, NULL, NULL, array('style' => 'errorSummary alert alert-danger')) ?>

I dont see how you can add such a thing to widgetfactory, so you just have to do it like this or wait for someone else to answer that part.