0

我是 CakePHP 的新手,我需要你们的帮助...!!

我有一个名为 ContactusController.php 的控制器,我在其中放置了这个关联:

$customerStatuses = $this->Contactus->CustomerStatus->find('list');
$enquiryTypes = $this->Contactus->EnquiryType->find('list');
$this->set(compact('customerStatuses', 'enquiryTypes'));                      

在 ctp 文件中,我有这个内部表格:

echo "<div class='control-group'>\n";
        echo "". $this->Form->input('enquiry_type_id', array('type'=>'select', 'label' => 'Type Of Enquiry')) ."\n";
        echo "</div>\n";

        echo "<div class='control-group'>\n";
        echo "". $this->Form->input('customer_status_id', array('type'=>'select', 'label' => 'Customer Type')) ."\n";
        echo "</div>\n";

在模型中我也做了这样的关联:

public $belongsTo = array(
    'CustomerStatus' => array(
        'className' => 'CustomerStatus',
        'foreignKey' => 'customer_status_id',
        'conditions' => '',
        'fields' => '',
        'order' => ''
    ),
    'EnquiryType' => array(
        'className' => 'EnquiryType',
        'foreignKey' => 'enquiry_type_id',
        'conditions' => '',
        'fields' => '',
        'order' => ''
    )
);

但我看不到 CustomerStatus 和 EnquiryStatus 的下拉列表。当我单击提交按钮时,只有它出现。我不知道我遇到了什么问题

请帮帮我。

4

1 回答 1

0

试试这个它可能会工作......

echo $this->Form->input('enquiry_type_id', array(
    'label' => 'enquiry',
    'id' => 'enquiry_id',
    'options' => 'post your array which contains the options'
));
于 2013-02-08T06:57:45.530 回答