One of the things i do like about the CHtml class, is the errorSummary function. I wonder if theres a way to pass all models available to it. In order to collect all user errors in one place. Maybe using the register pattern by letting all models registering themselves. Does Yii has such a class?
//prepare parameter arrays. Maybe this can be done in controller or model,
//whereas the html output might be done in the view.
echo CHtml::openTag('div', $aDivParams));
echo CHtml::link($label, $url, $aLinkParams);
This is probably not a very good example of what CHtml is good for. In most cases it makes no sense in using the CHtml class to generate HTML Tags.
It is probably also very useful to generate external links.
For internal links, however it is very useful.
Consider the following example:
You have a Site controller that contains a login action.
In your Routes you’ve then defined /login to point to /site/login
When you generate the link using
Yii will automatically consider that route and change the link to just /login
For internal links, Yii will also prepend the base url, which is very useful if your application may not be installed in the domain’s root directory.
The CHtml class is also very useful for forms, because it will automatically preset the correct values in input fields and mark the input fields with a special CSS error class in case there were any validation errors.