So I have a MVC for Events and Event Categories. I am trying to have
the name of the category appear on the event page. I am associating
events as belonging to event categories with a field called cat_id.

I am able the retrieve the tables, but for some reason the event
category part of the array ends up empty.

Visually I am trying to make it look something like:
Concert: Annual Event

Where Concert is equal to a cat_name which is associated by cat_id(in
the event table) = id(in the event categories table) and Annual Event
is the event_title (in the event table). Also the word concert would
be linked to show a category view

Getting data from the event table is no problem.

I used print_r($event[0]) to show data from the first entry:
[code]Array ( [Event] => Array ( [id] => 6 [cat_id] => 1 [gallery_id]
=> 6 [event_title] => Test [event_date] => 2008-02-09 [event_hour] =>
6 [event_minute] => 0 [event_ampm] => 1 [event_price] => 10.00
[event_tickets] => 6 [event_venue] => Venue [event_address] => Address
[event_city] => San Jose [event_state] => CA [event_zip] => 95123  )
[EventCategory] => Array ( [id] => [cat_name] => [cat_description]
=> ) ) [/code]

If you notice the EventCategory part of the array is empty for some
reason....

Event Model:
[code]<?php
class Event extends AppModel
{
        var $name = 'Event';
        var $hasOne = array(
                'EventCategory' => array(
                        'className'     =>      'EventCategory',
                        'foreignKey' => 'id'
                        )
                );
}
?>
[/code]

Event Category Model:
[code]
<?php
class EventCategory extends AppModel
{
        var $name = 'EventCategory';
        var $hasMany = array(
                'Event' => array(
                        'className'     =>      'Recipe',
                        'order'         =>      'Reciped
}
?>
[/code]

Event Controller:
[code]
<?php
class EventController extends AppController
{
        var $name = 'Event';

        function index()
        {
                $this->set('event', $this->Event->findAll());
        }
}
?>
[/code]

Event Category Controller:
[code]
<?php
class EventCategoryController extends AppController
{
        var $name = 'EventCategory';

        function index()
        {
                $this->set('eventcategory', $this->EventCategory->findAll());
        }
}
?>
[/code]

Sorry, I know this is a bit lengthy, but I figured I would give a
bunch of details rather than be vague. Hope someone can help. Also I
don't thing their is a [code] tag here, but it separates things nicely
anyways.

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to