Tuesday, February 23, 2010

Re: how to adress specific data from related models?

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 <p...@webbedit.co.uk> 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 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: