custom error messages


i want to have custom error messages for my forms,

so if i use the message property in the validation rules like:

array(‘username, password’, ‘required’, ‘message’=>‘is required’),

but when it is empty i just get the message whitout the attribute name before the error shows:

  • is required

  • is required

instead of :

-username is required

-password is required

how can i do this?

thanks in advance.

Look here

thanks allot, i found it.

I have a problem with the custom error message…

Here is my situation.

I am calling data from the ‘turnover’ table in my _form as such:

ID | Name

1 |

2 | R0m - R1.5m

3 | R1.5m - R2.5m

4 | R2.5m - R3m

and placing the ID value into my business table.

i.e. the Names from the turnover database are shown to the user, but the ID’s from the turnover database are stored in the business database. Here is the code below for those that need this same functionality… (as found in my _form view)

<div class="row">

	<?php $turnover = BizTurnover::Model()->findAll(); ?>

	<?php echo $form->labelEx($model,'turnover'); ?>

	<?php echo $form->dropDownList($model,'turnover', CHtml::listData($turnover, 'turnover_id', 'name')); ?>

	<?php echo $form->error($model,'turnover'); ?>


<br class="Apple-interchange-newline">

In my business model I need the validator to activate (show an error that he has NOT selected a value) when the user does not make a selection… but the default selection is ID 1… which shows as blank… but is actually an ID of 1!.. because it has an ID, the validator says that there is a value, and therefore no error is shown, so I’ve decided as a work-around, I’ll let the validator use the min/max feature, but obviously the error that comes up is not really correct for the user. So to change the error I created a custom error…

array('turnover', 'numerical', 'min'=>2, 'message'=>'Please select a value.'),

The problem now is that the custom error does not display, it never changes no matter what I do!

Am I doing this whole process incorrectly? Or am I doing something wrong?

Kind Regards,


Double posting is not really liked here :)

Please see