I'm using Cake 1.2.3.8166.
My problem is $this->Model->validates() ALWAYS RETURN TRUEE!!!!!
Here is my Model file:
<?php
class Applicant extends AppModel {
var $name = 'Applicant';
var $validate = array(
'nokp' => array(
'nokpRule-1'=> array(
'rule'=> array('maxLength', 12),
'message'=>'Maksimum aksara ialah 12 sahaja.',
'required'=>'true'
),
'nokpRule-2' => array(
'rule'=>'alphaNumeric',
'message' => 'No Kad Pengenalan mesti menggunakan
nombor DAN perkataan ATAU nombor sahaja.')
),
'gelaran' => array(
'rule'=>'notempty',
'message'=>'Gelaran mesti dipilih.'
),
'nama' => array(
'namaRule-1'=> array(
'rule'=> array('maxLength', 100),
'message'=>'Maksimum aksara ialah 100 sahaja.',
'required'=>'true'
),
'namaRule-2' => array(
'rule'=> array('custom', '/[a-zA-Z][^0-9]/'),
'message' => 'Nama mesti munggunakan perkataan
sahaja.')
),
'tarikh_lahir' => array(
'rule'=>'date',
'message'=>'Tarikh mesti di dalam format yang betul.'
),
'emel' => array(
'rule'=>'email',
'message'=>'Emel mesti ditulis dengan format yang betul.'
),
'jawatan' => array(
'rule'=>'notempty',
'message'=>'Jawatan mesti diisi.'
),
'skim' => array(
'rule'=>'notempty',
'message'=>'Skim mesti dipilih.'
),
'gred' => array(
'rule'=>'notempty',
'message'=>'Gred mesti dipilih.'
),
'tarikh_lantikan' => array(
'rule'=>'date',
'message'=>'Tarikh mesti di dalam format yang betul.'
),
'gaji' => array(
'rule'=>'numeric',
'message'=>'Gaji mesti diisi dan dalam bentuk nombor
sahaja.'
),
'tanggungan' => array(
'rule'=>'notempty',
'message'=>'Tanggungan mesti dipilih.'
),
'status_kahwin' => array(
'rule'=>'notempty',
'message'=>'Status kahwin mesti dipilih.'
),
'negeri' => array(
'rule'=>'notempty',
'message'=>'Negeri mesti dipilih.'
),
'no_telefon_pejabat' => array(
'rule'=>'numeric',
'message'=>'No telefon pejabat mesti diisi dan dalam
bentuk nombor sahaja.'
),
'application_id' => array('notempty')
);
//The Associations below have been created with all possible keys,
those that are not needed can be removed
var $belongsTo = array(
'Application' => array(
'className' => 'Application',
'foreignKey' => 'application_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
}
?>
And here is the controller function:
function KJForm () {
// Setting data for validaton by the model
$this->Applicant->set($this->data);
if ($this->Applicant->validates()) {
// ALWAYS RETURN TRUE
} else {
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---