Jeremy Burns
jeremyburns@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 <jeremybu...@me.com> 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:
>>> <?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 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+unsubscribe@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+unsubscribe@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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
No comments:
Post a Comment