如何显示自定义窗体下拉列表标签?
问题描述:
我无法弄清楚如何在窗体中编辑cakephp 2.0的标签输出。如何显示自定义窗体下拉列表标签?
我有一个简单的下拉列表有3个项目,我想要做的就是改变文本输出(这当然打印字段名)我怎么做。我看了1.3和2.0的文档,我无法弄清楚;
echo $this->Form->input('accounttype', array('options'=>array('customer' => 'Customer', 'retailer' => 'Retailer','manufacturer'=>'Manufacturer')));
答
使用标签属性来实现这一目标:
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
答
只需添加label
属性:
echo $this->Form->input('accounttype', array('label' => 'Account Type'));
非常感谢你所做的看起来很容易,花一个小时试图做到这一点:) – 2012-03-07 12:05:26