Forms 使用CakePHP3中的表单帮助器创建一个SelectBox

Forms 使用CakePHP3中的表单帮助器创建一个SelectBox,forms,cakephp,helper,Forms,Cakephp,Helper,我正在尝试为编辑页面创建一个组合框 echo $this->Form->select('status', ['empty' => 'Select Status'], ['class' => 'form-control', 'required'] ); 在这里,我想补充两件事: $options = array('0' => '

我正在尝试为编辑页面创建一个组合框

echo $this->Form->select('status', 
                        ['empty' => 'Select Status'], 
                        ['class' => 'form-control', 'required']
                    );
在这里,我想补充两件事:

$options = array('0' => 'Inactive',
                 '1' => 'Active',
                );
和选定值。假设这是$status

我尝试了不同的选项,但有时它不添加类,有时它在标签中显示选项

如果有人提供线索就好了

谢谢


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