Saturday, April 3, 2010

Dropdownlist issue

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: