I already fixed that at some point whilst looking for the problem. My classes
now look like this:
class Location extends AppModel
{
var $name = 'Location';
var $hasMany = array(
'Rental' => array(
'className' => 'Rental',
'order' => 'Rental.created DESC'
)
);
class Rental extends AppModel
{
var $name = 'Rental';
var $hasOne = array(
'Rate' => array(
'className' => 'Rate',
'foreignKey' => 'rental_id',
'dependent' => true
)
);
var $belongsTo = array(
'Location' => array(
'className' => 'Location'
)
);
}
class Rate extends AppModel
{
var $name = 'Rate';
var $belongsTo = array(
'Rental' => array(
'className' => 'Rental'
)
);
}
Thanks.
John Andersen-6 wrote:
>
> You probably get the warning due to the following:
>
> [code]
> class Rate extends AppModel
> {
> var $name = 'Rate';
> var $belongsTo = 'Rentals';
> }
> [/code]
>
> Observe that you have given your Rental model as Rentals in the
> belongsTo association! Fix that and the warning should go away. Enjoy,
> John
>
> On Jan 15, 9:34 pm, koala kid <[email protected]> wrote:
>> Thanks, that fixed it. For some reason I had Rate/ instead of Rate. in my
>> HTML form as the input name, changing that and its now saving. Thanks for
>> the tip.
>>
>> However I've now got another issue! When I submit the form the data is
>> being
>> saved but I get a PHP warning:
>>
>> Warning (2): Illegal offset type in unset
>> [CORE/cake/libs/model/model.php,
>> line 561]
>>
>> Code | Context
>>
>> $params = array(
>> "belongsTo" => array(
>> "Location" => array()
>> )
>> )
>> $reset = true
>> $models = array(
>> "Location" => array(
>> "className" => "Location"
>> )
>> )
>> $assoc = "belongsTo"
>> $model = array(
>> "className" => "Location"
>> )
>>
>> foreach ($models as $model) {
>> $this->__backAssociation =
>> array_merge($this->__backAssociation, $this->{$assoc});
>> unset ($this->__backAssociation[$model]);
>>
>> Model::unbindModel() - CORE/cake/libs/model/model.php, line 561
>> RentalsController::edit() - APP/controllers/rentals_controller.php, line
>> 91
>> Object::dispatchMethod() - CORE/cake/libs/object.php, line 116
>> Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 227
>> Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 194
>> [main] - APP/webroot/index.php, line 88
>>
>> It looks like I still haven't got my head around this ORM thing. Have I
>> set
>> up my associations correctly?
>>
>> Thanks for your help.
>>
> [snip]
>
> 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
>
>
--
View this message in context:
http://old.nabble.com/Unable-to-save-related-table-information-tp27153345p27182900.html
Sent from the CakePHP mailing list archive at Nabble.com.
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