Hi All, I'm new to Cake and while I feel I have a good grasp of many
of the concepts and conventions I have stumbled across the following
problem. It's probably a simple lack of convention following, but
I've read the manual over and over and I feel this should work.
Hopefully my description will be succinct!
I have 3 tables: groups, requests and request_statuses.
A single request belongs to a single group and it has a single
status. Hence a single group has many requests, as does a single
request_status.
I created the tables are follows (note: the request_statuses and the
groups tables will be modified by an admin, and so I'd rather the ids
were words than integers):
CREATE TABLE `requests` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(32) NOT NULL,
`request_status_id` varchar(16) NOT NULL default 'submitted',
`group_id` varchar(8) NOT NULL default 'unknown',
PRIMARY KEY (`id`)
)
CREATE TABLE `request_statuses` (
`id` varchar(16) NOT NULL,
`name` varchar(16) NOT NULL,
PRIMARY KEY (`id`)
)
CREATE TABLE `groups` (
`id` varchar(8) NOT NULL,
`name` varchar(16) NOT NULL,
PRIMARY KEY (`id`)
)
The models look like:
app/models/requests.php:
class Request extends AppModel
{
var $belongsTo = array(
'RequestStatus',
'Group'
);
}
app/models/request_statuses.php:
class RequestStatus extends AppModel
{
var $hasMany = array(
'Request'
);
}
app/models/groups.php:
class Group extends AppModel
{
var $hasMany = array(
'Request',
);
}
If I create a app/controllers/requests_controller.php thus:
class RequestsController extends AppController
{
var $scaffold;
}
then when I access this page to list the requests - the 'Group' column
in the resulting table is laid out correctly with links to the groups
pages, but the 'Request Status' contains the error:
"Notice: Undefined index: request_status_id in cake/libs/view/
templates/scaffolds/index.thtml on line 79"
I also note that the scaffolding index page for request_statuses shows
the errors:
Warning: Invalid argument supplied to foreach() in cake/libs/
controller/controller.php on line 666
Warning: Invalid argument supplied to foreach() in cake/libs/
controller/controller.php on line 801
As far as I can tell I've done everything right. Can anyone a) tell
me why I get the error, and/or b) while you're at it generally point
out and misunderstandings I may have demonstrated in my understanding
of cake.
I've tried refactoring everything down so that the 2 words "request
status" become the single word "requeststatus", and that works.
Obviously I could stick with this, but I feel it could and should be
better.
Many thanks for reading this far and for giving it some thought.
Chris
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---