Hello...My dear friends today is the most valuable lesson you ever had.This is 'Data validation'.
I need to say that is very easy in CakePhp.
Lets start.
You need to put the validation rules in model file.So add the below codes in the model file.
Here ID and Name are the table fields.
public $validate=array(
'ID'=>array(
'rule'=>array('minLength',8),
'message'=>'Enter a good ID which has at least 8 characters'
),
'Name'=>array(
'rule'=>'alphaNumeric',
'required'=>true
)
);
That is it.Go to the web browser and and load the form as we done in CURD 02 lesson.And add a ID which has got less than 8 characters.
And submit.You will see the error message.
-Ujitha Manuja Sudasingha-
I need to say that is very easy in CakePhp.
Lets start.
You need to put the validation rules in model file.So add the below codes in the model file.
Here ID and Name are the table fields.
public $validate=array(
'ID'=>array(
'rule'=>array('minLength',8),
'message'=>'Enter a good ID which has at least 8 characters'
),
'Name'=>array(
'rule'=>'alphaNumeric',
'required'=>true
)
);
That is it.Go to the web browser and and load the form as we done in CURD 02 lesson.And add a ID which has got less than 8 characters.
And submit.You will see the error message.
-Ujitha Manuja Sudasingha-