If you are doing this from within the BookingPosition model, '$this' points to 
the BookingPosition model. So by trying to access $this->BookingPosition you 
are in fact trying to access $this->BookingPosition->BookingPosition, if that 
makes sense! Instead, try $this->Lodging->field...etc. This should work, so 
long as you have a relationship set up between BookingPosition and Lodging in 
the models. If you are accessing this from a controller, then you need to use 
$this->BookingPosition->Lodging...etc

Jeremy Burns
[email protected]


On 24 Feb 2010, at 07:26, mivogt-LU wrote:

> Hello Paul,
> 
> sadly there seems to be an error in adressing the model the way you
> told me:
> 
> Notice (8): Undefined property: BookingPosition::$BookingPosition [APP
> \models\booking_position.php, line 78]
> Notice (8): Trying to get property of non-object [APP\models
> \booking_position.php, line 78]
> Fatal error: Call to a member function field() on a non-object in D:
> \x173\xampp\htdocs\myca\app4\myapp\models\booking_position.php on line
> 78
> 
> with line 78 as you suggested
> 
>> $numberOfBeds = $this->BookingPosition->Lodging->field('numberOfBeds', 
>> array('Lodging.id'=>$this->data['Lodging']['id']));
> 
> I can access i.e. number of kids form the model like this:
> $K = $this->data['BookingPosition']['AnzahlKinder'];
> 
> so $this->BookingPosition->... do not loook that wrong to me...
> 
> 
> Any idea why it does not work and how to work around?
> 
> TIA
> 
> Michael
> 
> 
> On 23 Feb., 10:18, WebbedIT <[email protected]> wrote:
>> If I understand your model and field names correctly, after submitting
>> your BookingPosition form which includes the field Lodging.id, you
>> should be able to use:
>> 
>> $numberOfBeds = $this->BookingPosition->Lodging->field('numberOfBeds',
>> array('Lodging.id'=>$this->data['Lodging']['id']));
>> 
>> For more info on the Model->field() method see:
>> 
>> http://book.cakephp.org/view/453/field
>> 
>> HTH
>> 
>> 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 [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

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

Reply via email to