提交表单后,不显示Cake PHP下拉列表

时间:2013-02-08 06:51:10

标签: php cakephp

我是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的下拉列表。当我点击提交按钮然后只显示它。我不知道我是什么问题havine

请帮帮我。

1 个答案:

答案 0 :(得分:0)

试试这可能有用......

echo $this->Form->input('enquiry_type_id', array(
    'label' => 'enquiry',
    'id' => 'enquiry_id',
    'options' => 'post your array which contains the options'
));