how display error message for a particular html field

i am performing validation in Cformmodel and displaying error if i want to display error for a particular active html field what should i do…i.e i have many validation in rules function but i am in need of displaying error for particular html field what should i do for that…someone clear me

You can do something like this in your view for each attribute:


echo ($model->getError('attributeName')) ? '<div class="fieldError">'.$model->getError('attributeName').'</div>':'';


<?php echo CHtml::error($model, $attribute); ?>