Want To Highlight Many Attributes In Ui For A Single Attribute Rule Error

Hi guys,

In a model I have a rule set for a attribute.

array('start_date', 'checkStartDate', 'skipOnError'=>true),

In checkStartDate, if a condition failed, I want to highlight two input fields to show that they are errors for those fields. Curently I’m using

$this->addError('start_date', 'Delivery Date and time should be a future date and time.');

but it only applies to stat_date attribute. If the condition failed, the above statement will execute, and because of that, On top of the view it will show the message and the start_date input box will be highlighted in red color.

With this I want ONLY to highlight another field called start_time. Is there a way to do it?

Thank you, for any help. :)

Try adding this:

$this->addError('start_time', '');

Hi Sinaru,

I am having the same problem… hope this might help u…

You can declare afterValidateAttribute method in clientOptions in the following way.

<?php $form=$this->beginWidget('CActiveForm', array(





            'afterValidateAttribute'=>'js:function(form, attribute, data, hasError){

                        var settings=form.data("settings");

                        var attributes=settings.attributes;


                                $.fn.yiiactiveform.updateInput(attribute,data, form);




)); ?>

After each attribute is validated, this script updates the error fields with latest json object received from the server.

It will not work when we set enableClientValidation as true and the validadtor has clientside validation option.


Thanks man. Exactly how I wanted it to be. :)