2017-10-20 11:45:50 2147次浏览 6条回答 1 悬赏 10 金钱

111111.png

报错

Call to a member function dropDownList() on a non-object

请问怎么解决

  • 回答于 2017-10-20 13:54 举报

    从错误信息上可以知道,你的$form应该是null

  • 回答于 2017-10-20 15:05 举报

    没有定义$form?
    试试模仿以下操作。

    $form = ActiveForm::begin([
        'method' => 'post',
        'action' => ['controller/action'],
    ]);
    ... your fields code ...
    ActiveForm::end();
    
  • 回答于 2017-10-20 15:59 举报
    [
        'attribute' => 'status',
        'label' => '状态',
        'format' => 'raw',
        'value' => function($model) {
            return Html::dropDownlist('status', $model->status, ['上架', '下架'], ['class' => 'form-control', 'onchange' => 'change("change-status",{status:this.value,id:' . $model->id . '})']);
        },
        'filter' => ['上架', '下架']
    ],
    
    觉得很赞
  • 回答于 2017-10-20 16:39 举报

    <?= $form->field($model, 'status')->dropDownList(['5'=>'启用','1'=>'关闭']) ?>

    , 觉得很赞
  • 回答于 2017-10-23 15:44 举报

    楼上正解,谁告诉你$form后边直接跟dropDownList的?

    1 条回复
    回复于 2017-10-24 17:58 回复

    活捉一枚大师

    觉得很赞
  • 回答于 2017-11-01 10:07 举报

    这个里面你能学到很多东西

    <?= $form->field($model, 'bus_type_res_id', ['template' => '{label}<div class="col-sm-8" style="display: inline-flex">{input}' . '{hint}{error}</div>', 'options' => ['class' => 'col_5']])
                                    ->dropDownList(ArrayHelper::map($data['bus_type']['data'], 'res_id', 'res_name'), ['class' => 'form-control ', 'style' => 'width:172px;']) ?>
    
    觉得很赞
您需要登录后才可以回答。登录 | 立即注册
this_summer
主管

this_summer 北京

注册时间:2017-04-07
最后登录:2023-06-25
在线时长:14小时55分
  • 粉丝2
  • 金钱630
  • 威望0
  • 积分770

热门问题