How to remove required label from LabelEx for a modal attribute


I am new to Yii and I need some help regarding the CActiveForm. I created a form and associated an active record with it. I have a filed account_name in the model which is required. Now for the view to create a new Account, when I inserted the labelex for the account name field, it shows a '* ’ sign after the label. I need to removed this sign from the interface as my CSS is alread designed to highlight the required field label.

I tried looking at the documentation and other resources and found that we can remove/customize this with the beforeRequiredLabel and afterRequiredLabel properties for CHtml class. But I am not been able to set these from the LabelEx method. Can anyone please help me with this?

Fr, here is the line I written for label,

<?php echo $form->labelEx($model,‘account_name’, array(‘label’=>‘Account Title’) ); ?>

and its output is Account Title *. I want to remove the * from the label, which is appended there as this is a required field in the model.

Thanks in advance,


use label instead of labelEx

<?php echo CHtml::activeLabel($model,'account_name',array('label'=>'Account Title'))?>

i think this is the best way

thanks, this helps.