禁用yii2中的activeform操作和方法

时间:2017-12-01 05:17:07

标签: php yii2

如何禁用yii2活动表单自动创建的表单方法和操作?

<div class="well">
              <?php $form = ActiveForm::begin([
                'action' => [''],'options' => ['method' => '']
                ]); ?>
              <?= $form->field($model, 'Title')->textInput(['maxlength' => true, 'style'=>'width:300px']) ?>

              <?= Html::button('Save', ['class' => 'btn btn-primary leavetype-save', 'value'=>'save']) ?>
           </div>
           <?php ActiveForm::end(); ?>

          </div>

1 个答案:

答案 0 :(得分:0)

不能通过参数。您需要覆盖public function dr($id) { $sql="SELECT * FROM tbl_delivery WHERE user_id = '$id'"; var_dump($sql); $stmt = $this->dbh->prepare($sql); $stmt->execute(); $data = array(); while($row = $stmt->fetch(PDO::FETCH_ASSOC)){ $data[] = $row; } return $data; } (尤其是run()方法)并手动呈现不带yii\widgets\ActiveFormaction选项的表单。