duanpao4172 2009-06-11 15:29
浏览 8

CakePHP - 关系表中的相关模型,显示在下拉列表中?

Given the following table structures:

Registered Participant model:

<?php
class RegisteredParticipant extends AppModel {
var $name = "RegisteredParticipant";
var $primaryKey = "id";
var $belongsTo = array(
  'EventLocation' => array('className' => 'EventLocation'),
  'RegistrationStatus' => array('className' => 'RegistrationStatus'),
  'Specialty' => array('className' => 'Specialty')
);
var $hasMany = array(
  'DietaryRestriction' => array('className' => 'DietaryRestriction')
);
}
?>

Event Location model:

<?php
class EventLocation extends AppModel {
   var $name = 'EventLocation';
   var $primaryKey = 'id';
   var $belongsTo = array(
      'Event' => array('className' => 'Event', 'foreignKey' => 'event_id'),
      'Location' => array('className' => 'Location', 'foreignKey' => 'location_id')
   );
}
?>

When I do this in my view: echo $form->input('RegisteredParticipant.EventLocation.moderator');

It returns a dropdown list of the EventLocation.ids, not the EventLocation.moderators like I expected. Any ideas what it could be?

  • 写回答

3条回答 默认 最新

  • doujian0265 2009-06-11 15:41
    关注

    Duh. $this->RegisteredParticipant->EventLocation->find() wasn't using 'all' as it's param.

    评论

报告相同问题?