我的控制器中有以下代码
$technicians = $this->Customer->Technician->find('list');
$account_managers = $this->Customer->Account_Manager->find('list');
$this->set(compact('technicians','account_managers'));
我的用户模型中有以下代码
public $hasMany = array(
'TicketComment' => array(
'className' => 'TicketComment',
'foreignKey' => 'user_id',
'dependent' => false,
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
),
'CustomerTech' => array(
'className' => 'Customer',
'foreignKey' => 'technician'
),
'CustomerManager' => array(
'className' => 'Customer',
'foreignKey' => 'account_manager'
)
);
我的客户模型中有以下代码
public $belongsTo = array(
'Technician' => array(
'className' => 'User',
'foreignKey' => 'technician',
'conditions' => '',
'fields' => '',
'order' => ''
),
'Account_Manager' => array(
'className' => 'User',
'foreignKey' => 'account_manager',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
在我看来,我有以下代码
<div class="control-group">
<?php echo $this->Form->label('technician', 'Technician', array('class' => 'control-label'));?>
<div class="controls">
<?php echo $this->Form->input('technician', array('class' => 'span12')); ?>
</div><!-- .controls -->
</div><!-- .control-group -->
<div class="control-group">
<?php echo $this->Form->label('account_manager', 'Account Manager', array('class' => 'control-label'));?>
<div class="controls">
<?php echo $this->Form->input('account_manager', array('class' => 'span12')); ?>
</div><!-- .controls -->
</div><!-- .control-group -->
在我看来,“技术员”显示为一个适当的自动选择框,但“Account_Manager”显示为一个简单的文本输入框。据我所知,两者的设置相同。那么为什么第二个输入没有形成选择框呢?