【问题标题】:how can i use bootstrap-UI to set select & radio box values我如何使用 bootstrap-UI 设置选择和单选框值
【发布时间】:2017-05-15 16:23:34
【问题描述】:

你好,我是 cakephp3 的大佬,我想使用 bootstrap-UI 来设置我的选择框和单选框值,例如 cakephp formhelper。

<?= $this->Form->select(
                        'field',
                        ['Low (7%)', 'middle(15%)', 'Quality (25%)', 'High (30%)'],['label'=>'Error Correction','class'=>'form-control']

                    ); ?>
                    <br/>


                    <?= $this->Form->radio(
                        'Image Format',
                        [
                            ['value' => 'png', 'text' => 'png', 'class'=>'radio-inline'],
                            ['value' => 'gif', 'text' => 'gif'],
                            ['value' => 'jpeg', 'text' => 'jpeg'],
                            ['value' => 'svg', 'text' => 'svg'],
                            ['value' => 'eps', 'text' => 'eps'],

                        ], ['checked' => 'true','label'=>'Image Format','class'=>'radio-inline']
                    ); ?>

谁能帮帮我,提前谢谢

【问题讨论】:

    标签: cakephp-3.x formhelper bootstrap-ui


    【解决方案1】:

    上面的例子正在运行,但我无法添加选项,因为我使用 bootstrap-ui 所以 我必须像这样使用控制而不是选择或收音机:

    <?= $this->Form->control('ecc', ['type' => 'select', 'label' => 'Error Correction', 'class' => 'form-control'
                            , 'options' => [['value' => 'Low (7%)', 'text' => 'Low (7%)'], ['value' => 'middle(15%)', 'text' => 'middle(15%)'], ['value' => 'Quality (25%)', 'text' => 'Quality (25%)'], ['value' => 'High (30%)', 'text' => 'High (30%)']]]); ?>
    
    
                        <br/>
    
                            <?= $this->Form->control(
                                'Format', ['type' => 'radio', 'checked' => 'true', 'label' => 'Image Format', 'class' => 'radio-inline',
                                    'options' => [
                                        ['value' => 'png', 'text' => 'png'],
                                        ['value' => 'gif', 'text' => 'gif'],
                                        ['value' => 'jpeg', 'text' => 'jpeg'],
                                        ['value' => 'svg', 'text' => 'svg'],
                                        ['value' => 'eps', 'text' => 'eps'],
    
                                    ]]
                            ); ?>
    

    【讨论】: