如何显示自定义表格下拉列表标签?

时间:2012-03-07 11:21:41

标签: php cakephp cakephp-2.0

我无法弄清楚如何通过表格中的cakephp 2.0编辑标签输出。

我有一个包含3个项目的简单下拉列表,我想要做的就是更改输出的文本(当然打印字段名称)我是怎么做的。我看了1.3和2.0文档,我无法弄明白;

echo $this->Form->input('accounttype', array('options'=>array('customer' => 'Customer', 'retailer' => 'Retailer','manufacturer'=>'Manufacturer')));

2 个答案:

答案 0 :(得分:1)

使用label属性实现此目的:

echo $this->Form->input(
    'accounttype', 
    array(
        'label' => 'Foo', 
        'options'=>array(
            'customer' => 'Customer', 
            'retailer' => 'Retailer',
            'manufacturer'=>'Manufacturer'
        )
    )
);

另见: http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html

答案 1 :(得分:0)

只需添加label属性:

echo $this->Form->input('accounttype', array('label' => 'Account Type'));