I have a gridview with date column (using CJuiDatepicker), it’s works perfect, but i want validate the input date, because the database don’t recognice some dates like “2011-10-”, or “2011-11”. I have to force the user to select a date from datepicker.
I make a rule in rules() method, and it works because it not make the query, but, it does not show me the errors like "Date is invalid".
Can you get the validation errors to work without the CJuiDatePicker? Are you providing a message for each custom validation rule?
For example…
public function rules()
{
return array(
...
array('thedate', 'length', 'max'=>12,), // <- message not necessary here, default is good
array('thedate', 'type', 'type' => 'date', 'message' => '{attribute}: is not a date!', 'dateFormat' => 'yyyy-MM-dd'),
...
);
}
Also, be sure you are displaying the errors in your form, if there are any.
You have right, the errors message don’t appers in any inputs, this is my rules
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('dateextrac, dateproc', 'required'),
array('dateextrac', 'length', 'max'=>12),
// I comment this.
//array('dateextrac, dateproc', 'safe', 'on'=>'search'),
The messages i don’t know how to show them, because i have to include them joined with the input, below it.
But, i think the input has to colored red automatic, or not?