2016-04-25 44 views
-1

我有一個下拉菜單,當光標懸停時顯示默認顏色。如何更改Cakephp3輸入類型中的選項樣式

echo $this->Form->input('filter_company', array(
    'label' => ' ', 'type' => 'select', 
    'class'=>'drop', 
    'style'=>'padding-left: 40px;', 
    'options' => $company, 
    'empty' => 'Empresa', 
    'id' => 'filto1', 
    'onChange'=>'document.getElementById("filto1").submit();' 
));?> 

我認爲解決辦法是創造了「選項」的數組,像這樣:

echo $this->Form->input('filter_company', array(
    'label' => ' ', 
    'type' => 'select', 
    'class'=>'drop', 
    'style'=>'padding-left: 40px;', 
    'options' => ['SOMETHING' => $company, 'class'=>'class_name'], 
    'empty' => 'Empresa', 
    'id' => 'filto1', 
    'onChange'=>'document.getElementById("filto1").submit();' 
));?> 

我的問題是知道要放什麼「東西」的地方。有人知道這些「選項」數組的適當結構,或者其他方式來更改選項:懸停樣式?

回答

0

我猜你是想爲每個選項

設置不同的屬性,所以要根據manual你必須創建這樣

'options' => [ 
    [ 'text' => 'Description 1', 'value' => 'value 1', 'class' => 'class_name' ], 
    [ 'text' => 'Description 2', 'value' => 'value 2', 'class' => 'another_name' ], 
    [ 'text' => 'Description 3', 'value' => 'value 3', 'class' => 'a_third_class' ] 
    ], 
+0

數組讓我試試吧! –

+0

我只是不知道這是否適用於我的變量$ company。 –

+0

你必須修改你的$ company數組才能獲得類似於我的例子中的數組 – arilia

相關問題