validation methods on my own.
It would be great if someone in here might give me a good start and
help me to do my first steps ...
I am using 2 models linked with each other
lodgings : id, roomnumber, amountofbeds, ...
bokkingpositions: id, lodging_id, amountkids amountyoungsters,
amountadults
Now I would like to check if there are enough beds for the people
typed in the add-view of booking-positions.
This for I thought of doing a new validation rule in validation array
and add me an own function to the model for the validating.
Here I have 2 problems.
1.) I do not know hot to access the posted data inside the model.
I tried $data[amountadult] and $data['amountadult'] both results with
an unknown index error.
2.) if I add an error message in my validate-array, it is not shown
below the field. Only the red bar below the field is shown without my
message.
some code snips:
Model:
<?php
class BookingPosition extends AppModel {
var $name = 'BookingPosition';
var $displayField = 'id';
...
var $validate=array
(
'amountadult' => array(
'rule'=>array('limitPersonen'),
'message'=>"to many persons"
),
);
function limitPersonen($data)
{
// $a1 = $data['amountadult'] ... wont work, indes
not found :(
return false; //( simulate all amount persons>number of beds
}
Pleas give me some help to start over - TIA
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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
No comments:
Post a Comment