create.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. use yii\widgets\ActiveForm;
  3. use common\helpers\Url;
  4. use common\helpers\Html;
  5. $form = ActiveForm::begin([
  6. 'id' => $model->formName(),
  7. 'enableAjaxValidation' => true,
  8. 'validationUrl' => Url::to(['create']),
  9. 'fieldConfig' => [
  10. 'template' => "<div class='row'><div class='col-sm-3 text-right'>{label}</div><div class='col-sm-9'>{input}\n{hint}\n{error}</div></div>",
  11. ]
  12. ]);
  13. ?>
  14. <div class="modal-header">
  15. <h4 class="modal-title">基本信息</h4>
  16. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
  17. </div>
  18. <div class="modal-body">
  19. <?= $form->field($model, 'username')->textInput()->hint('创建以后无法修改,请确认后认真填写'); ?>
  20. <?= $form->field($model, 'password')->passwordInput(); ?>
  21. <?= $form->field($model, 'role_ids')->widget(\kartik\select2\Select2::class, [
  22. 'data' => $model->roles,
  23. 'options' => [
  24. 'placeholder' => '选择授权角色',
  25. 'multiple' => true
  26. ],
  27. 'pluginOptions' => [
  28. 'tags' => true,
  29. 'tokenSeparators' => [',', ' '],
  30. 'maximumInputLength' => 20
  31. ],
  32. ]);?>
  33. <?= Html::modelBaseCss(); ?>
  34. </div>
  35. <div class="modal-footer">
  36. <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
  37. <button class="btn btn-primary" type="submit">保存</button>
  38. </div>
  39. <?php ActiveForm::end(); ?>
粤ICP备19079148号