2012-03-07 92 views
0

我無法弄清楚如何在窗體中編輯cakephp 2.0的標籤輸出。如何顯示自定義窗體下拉列表標籤?

我有一個簡單的下拉列表有3個項目,我想要做的就是改變文本輸出(這當然打印字段名)我怎麼做。我看了1.3和2.0的文檔,我無法弄清楚;

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

回答

1

使用標籤屬性來實現這一目標:

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

+0

非常感謝你所做的看起來很容易,花一個小時試圖做到這一點:) – 2012-03-07 12:05:26

0

只需添加label屬性:

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