Hi there I am a bit confused about some habit of my cake app.
I did my database and built all files using cake bake as usual.
Then I added my validation rules manually - doing a small function for
the validation I need, adding it in the validation array of the model.
Both models do use the functions for validating data as I suppose em
to do.
But in the one model my error-message is shown in the red box below
the field,
the oher model shows the red box below the field but without the
message.
It is that strange to me as I did copy and paste most of the
validation codes.
Hope someone might have an idea why two times the same or similar code
does so different...
1st model: customers
var $validate=array
(
'Telefon' =>
array('rule'=>'CheckKontaktdaten','message'=>'mind. 1
Kontaktart ist notwendig'),
'Fax' =>
array('rule'=>'CheckKontaktdaten','message'=>'mind. 1
Kontaktart ist notwendig'),
'Mobil' =>
array('rule'=>'CheckKontaktdaten','message'=>'mind. 1
Kontaktart ist notwendig'),
'Email' =>
array('rule'=>'CheckKontaktdaten','message'=>'mind. 1
Kontaktart ist notwendig')
);
function CheckKontaktdaten()
{
$DataOK = false;
$T = $this->data['Customer']['Telefon'];
$F = $this->data['Customer']['Fax'];
$M = $this->data['Customer']['Mobil'];
$E = $this->data['Customer']['Email'];
$K1 = strlen ($T);
$K2 = strlen ($F);
$K3 = strlen ($M);
$K4 = strlen ($E);
if ( (int)$K1>4 or (int)$K2>4 or (int)$K3>4 or
(int)$K4>4 ) $DataOK
= true;
return $DataOK ;
}
--------
2nd model - booking_positions
var $validate=array
(
'AnzahlErwachsene' => array('rule'=>'limitPersonen','message'=>'zu
viele Gäste'),
'AnzahlJugendliche' => array('rule'=>'limitPersonen','message'=>'zu
viele Gäste'),
'AnzahlKinder' => array('rule'=>'limitPersonen','message'=>'zu
viele
Gäste')
);
function limitPersonen()
{
$E = $this->data['BookingPosition']['AnzahlErwachsene'];
$J = $this->data['BookingPosition']['AnzahlJugendliche'];
$K = $this->data['BookingPosition']['AnzahlKinder'];
$Y1=$this->Lodging-
>find('first',array('conditions'=>array('Lodging.id'=>$this-
>data['BookingPosition']['lodging_id'])));
$numberOfBeds =(int)$Y1['Lodging']['Bettenanzahl'];
$X = (int)$E + (int)$J + (int)$K;
return ((int)$X <= $numberOfBeds) ; //($AnzE + $AnzJ + $AnzK)<$maxAnz;
}
------------
both do the check and both do the red box below the datafield.
customer model shows me the msg, booking_position not.
Any help welcome ...
CU
Michael
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
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
To unsubscribe from this group, send email to
cake-php+unsubscribegooglegroups.com or reply to this email with the words
"REMOVE ME" as the subject.