2016-08-24 58 views
1

我想为编辑页面创建一个组合框。在CakePHP3中使用Form Helper创建一个SelectBox

echo $this->Form->select('status', 
         ['empty' => 'Select Status'], 
         ['class' => 'form-control', 'required'] 
        ); 

这里我想补充两两件事:

$options = array('0' => 'Inactive', 
       '1' => 'Active', 
       ); 

和选择的值。假设这是$状态;

我试着用不同的选择,但有时它不添加类和有时候它显示在标签

选择这将是巨大的,如果有人给线索。

感谢

回答

1
<?= $this->Form->input('status', 
[ 
'type' => 'select', 
'options' => ['0' => __('Inactive') , '1' => __('Active')], 
'empty' => __('Select Status'), 
'class' => 'form-control', 
'required' => true, 'label' => __('Type') 
] 
) 
?> 
相关问题