Re: Need help with custom validation please

2010-02-24 Thread WebbedIT
All too often guilty of the same myself :o)

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Need help with custom validation please

2010-02-23 Thread Jeremy Burns
Good spot Paul - I replied too quickly!

Jeremy Burns
jeremybu...@me.com
On 23 Feb 2010, at 09:21, WebbedIT wrote:

> Your data should have been available at:
> 
> $this->data['BookingPosition']['amountofadult']
> 
> not
> 
> $this->data['booking_positions']['amountofadult']
> 
> Just clarifying this in case other newbies read this post and get
> confused.
> 
> Paul.
> 
> 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+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Need help with custom validation please

2010-02-23 Thread WebbedIT
Your data should have been available at:

$this->data['BookingPosition']['amountofadult']

not

$this->data['booking_positions']['amountofadult']

Just clarifying this in case other newbies read this post and get
confused.

Paul.

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Need help with custom validation please

2010-02-23 Thread mivogt-LU
Great it works. Thank u so much, Jeremy!!
It took me hours for try and error with no result - now the solution
is easy and clear and logical :)
Think I 'll never forget the mistake and the right way.
Thank u again.

Michael

On 23 Feb., 09:54, Jeremy Burns  wrote:
> Probably - it sounds right. Debug $this->data and check.
>
> Jeremy Burns
> jeremybu...@me.com
> (Skype) +44 208 123 3822 (jeremy_burns)
> (m) +44 7973 481949
> (h) +44 208 530 7573
>
> On 23 Feb 2010, at 08:47, mivogt-LU wrote:
>
> > Hi Jeremy,
>
> > thank you, might I ask if I got the point:
>
> > .. (something like $this->data['Model']['field'].  ..
> > my database table is named    booking_positions
> > my php file fot the model named booking_position.php
>
> > so I have to use $this->data['booking_positions']['amountofadult'] ?
>
> > TNX
>
> > Michael
>
> > On 23 Feb., 09:35, Jeremy Burns  wrote:
> >> The data is accessible via $this->data. If you debug it you'll see the 
> >> shape of the array so you check values within it (something like 
> >> $this->data['Model']['field']. Your custom validation function should 
> >> return either true or false. If it returns false, your validation error 
> >> should be set for the field and therefore appear on the form.
>
> >> Jeremy Burns
> >> jeremybu...@me.com
>
> >> On 23 Feb 2010, at 08:30, mivogt-LU wrote:
>
> >>> hi there, I have some problems doing my first cake and adding some
> >>> 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:
> >>>  >>> 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 sitehttp://cakeqs.organdhelp 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+unsubscr...@googlegroups.com For more options, visit this group 
> >>> athttp://groups.google.com/group/cake-php?hl=en
>
> > Check out the new CakePHP Questions sitehttp://cakeqs.organd 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+unsubscr...@googlegroups.com For more options, visit this group 
> > athttp://groups.google.com/group/cake-php?hl=en

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Need help with custom validation please

2010-02-23 Thread Jeremy Burns
Probably - it sounds right. Debug $this->data and check.

Jeremy Burns
jeremybu...@me.com
(Skype) +44 208 123 3822 (jeremy_burns)
(m) +44 7973 481949
(h) +44 208 530 7573

On 23 Feb 2010, at 08:47, mivogt-LU wrote:

> Hi Jeremy,
> 
> thank you, might I ask if I got the point:
> 
> .. (something like $this->data['Model']['field'].  ..
> my database table is namedbooking_positions
> my php file fot the model named booking_position.php
> 
> so I have to use $this->data['booking_positions']['amountofadult'] ?
> 
> TNX
> 
> Michael
> 
> 
> On 23 Feb., 09:35, Jeremy Burns  wrote:
>> The data is accessible via $this->data. If you debug it you'll see the shape 
>> of the array so you check values within it (something like 
>> $this->data['Model']['field']. Your custom validation function should return 
>> either true or false. If it returns false, your validation error should be 
>> set for the field and therefore appear on the form.
>> 
>> Jeremy Burns
>> jeremybu...@me.com
>> 
>> On 23 Feb 2010, at 08:30, mivogt-LU wrote:
>> 
>>> hi there, I have some problems doing my first cake and adding some
>>> 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:
>>> >> 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 sitehttp://cakeqs.organd 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+unsubscr...@googlegroups.com For more options, visit this group 
>>> athttp://groups.google.com/group/cake-php?hl=en
> 
> 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+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Need help with custom validation please

2010-02-23 Thread mivogt-LU
Hi Jeremy,

thank you, might I ask if I got the point:

 .. (something like $this->data['Model']['field'].  ..
my database table is namedbooking_positions
my php file fot the model named booking_position.php

so I have to use $this->data['booking_positions']['amountofadult'] ?

TNX

Michael


On 23 Feb., 09:35, Jeremy Burns  wrote:
> The data is accessible via $this->data. If you debug it you'll see the shape 
> of the array so you check values within it (something like 
> $this->data['Model']['field']. Your custom validation function should return 
> either true or false. If it returns false, your validation error should be 
> set for the field and therefore appear on the form.
>
> Jeremy Burns
> jeremybu...@me.com
>
> On 23 Feb 2010, at 08:30, mivogt-LU wrote:
>
> > hi there, I have some problems doing my first cake and adding some
> > 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:
> >  > 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 sitehttp://cakeqs.organd 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+unsubscr...@googlegroups.com For more options, visit this group 
> > athttp://groups.google.com/group/cake-php?hl=en

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Need help with custom validation please

2010-02-23 Thread Jeremy Burns
The data is accessible via $this->data. If you debug it you'll see the shape of 
the array so you check values within it (something like 
$this->data['Model']['field']. Your custom validation function should return 
either true or false. If it returns false, your validation error should be set 
for the field and therefore appear on the form.

Jeremy Burns
jeremybu...@me.com


On 23 Feb 2010, at 08:30, mivogt-LU wrote:

> hi there, I have some problems doing my first cake and adding some
> 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:
>  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+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en

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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Need help with custom validation please

2010-02-23 Thread mivogt-LU
hi there, I have some problems doing my first cake and adding some
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:
 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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en