and the Category models! Have you defined it as such?
In case you have, the I would retrieve the list of categories from the
Category models as:
[code]
$this->Event->Category->find('list')
[/code]
That will give you each category with id and name, where the id will
be the array key and name the value.
Hope this helps you on the way,
John
On Apr 3, 10:09 am, mdb <meena.d...@gmail.com> wrote:
> Hi All,
>
> I'm having problem displaying a dropdownlist . basically i'm adding
> events to the DB.
>
> The Events entry page has a event category dropdown which also comes
> from db.
>
> So in the Events controller add/edit function i have the following
> code.
>
> $this->set('eventcategories', $this->Event->EventCategory-
>
> >find('all'));
>
> and in the Event Model I set
> var $belongsTo = array('EventCategory'=>
>
> array('className'=>'EventCategory','foreignKey'=>'categoryid'));
>
> Event category model
> var $belongsTo = array('Event'=>
> array('className'=>'Event','foreignKey'=>'eventid'));
>
> in the add.ctp
>
> <?php
>
> $options=array($eventcategories);
>
> echo $form->select('eventcategory',$options); ?>
>
> Events category table has 2 records: Major and Minor
>
> the dropdown displays like this
>
> EventCategory
>
> 1
>
> Major
>
> EventCategory
>
> 2
>
> Minor
>
> I simply want it to display
>
> Major
> Minor
>
> with ids(1,2) as value.. which should be stored in the Events Table
> and on Edit.ctp the saved category to be selected by default.
>
> Please help...
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
To unsubscribe, reply using "remove me" as the subject.
No comments:
Post a Comment