public function limitSelection($attribute,$params)
{
if(count($this->$attribute)>3)
$this->addError($attribute,"You are only allowed to select 3 or less items for ".$attribute);
}
Then declare the rules in the following way.
public function rules()
{
return array(
..................other rules......................
array('sub_id', 'required','message'=>"Select atleast one item for {attribute}"),
array('sub_id', 'limitSelection'),
);
..................other rules.....................
}
FORM
//Use CActiveForm OR CHtml::activeDropDownList to properly declare the name attribute.
echo CHtml::activeDropDownList($model,'sub_id', empty($model->section_id) ? array() : CHtml::listData(Subsection::model()->findAllByAttributes(array('section_id' => $model->section_id)),'sub_id','en_name'),array('multiple'=>'multiple'));
...