_form.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. use yii\helpers\Html;
  3. use yii\widgets\ActiveForm;
  4. /* @var $this yii\web\View */
  5. /* @var $model common\models\Page */
  6. /* @var $form yii\widgets\ActiveForm */
  7. ?>
  8. <div class="box box-success">
  9. <div class="box-body">
  10. <?php $form = ActiveForm::begin(); ?>
  11. <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
  12. <?= $form->field($model, 'slug')->hint('谨慎修改,需和小程序端保持一致')->textInput(['maxlength' => true]) ?>
  13. <?= $form->field($model, 'content')->widget(\common\widgets\EditorWidget::className(), $model->isNewRecord ? ['type' => request('editor') ?: config('page_editor_type')] : ['isMarkdown' => $model->markdown]) ?>
  14. <div class="form-group form-submit">
  15. <?= Html::submitButton($model->isNewRecord ? '创建' : '更新', ['class' => 'btn btn-flat bg-maroon btn-block']) ?>
  16. </div>
  17. <?php ActiveForm::end(); ?>
  18. </div>
  19. </div>
  20. <?php $this->beginBlock('js') ?>
  21. <script>
  22. $(document).on('change', '#choose-editor', function () {
  23. var url = '<?= \yii\helpers\Url::to(['create']) ?>';
  24. var type = $(this).val();
  25. url = url.addQueryParams({editor: type});
  26. location.href = url;
  27. })
  28. </script>
  29. <?php $this->endBlock() ?>