ajax-edit.php 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. use common\helpers\Url;
  3. use yii\widgets\ActiveForm;
  4. /** @var ActiveForm $form */
  5. /** @var \yii\db\ActiveRecord $model */
  6. $form = ActiveForm::begin([
  7. 'id' => $model->formName(),
  8. 'enableAjaxValidation' => true,
  9. 'validationUrl' => Url::to(['ajax-edit', 'id' => $model['id']]),
  10. 'fieldConfig' => [
  11. 'template' => "<div class='row'><div class='col-sm-2 text-right'>{label}</div><div class='col-sm-10'>{input}\n{hint}\n{error}</div></div>",
  12. ]
  13. ]);
  14. ?>
  15. <div class="modal-header">
  16. <h4 class="modal-title">基本信息</h4>
  17. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
  18. </div>
  19. <div class="modal-body">
  20. <?= $form->field($model, 'pid')->dropDownList($dropDownList) ?>
  21. <?= $form->field($model, 'title')->textInput(); ?>
  22. <?= $form->field($model, 'name')->textInput()->hint('如果填写内容是路由需要绝对路径; 例如: /main/index'); ?>
  23. <?= $form->field($model, 'sort')->textInput(); ?>
  24. </div>
  25. <div class="modal-footer">
  26. <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
  27. <button class="btn btn-primary" type="submit">保存</button>
  28. </div>
  29. <?php ActiveForm::end(); ?>
粤ICP备19079148号