_form.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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(['enableClientValidation'=>false]); ?>
  11. <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
  12. <?= $form->field($model, 'type',['options'=>['class'=>'hide']])->textInput(['maxlength' => true]) ?>
  13. <?php
  14. foreach ($configModels as $index => $configModel) {
  15. $value = explode("\r\n",$configModel['extra']);
  16. $arr = [];
  17. foreach($value as &$val){
  18. $val = trim($val);
  19. $arr[$val] = $val;
  20. }
  21. echo $form->field($model, 'id')->checkboxList($arr,[
  22. 'name'=>$configModel['name'],
  23. 'value'=>$model->filter[$configModel['name']]
  24. ])->label($configModel['description']);
  25. }
  26. ?>
  27. <?= $form->field($model, 'content')->widget(\common\widgets\EditorWidget::className(), $model->isNewRecord ? ['type' => request('editor') ?: config('page_editor_type')] : ['isMarkdown' => $model->markdown]) ?>
  28. <div class="form-group form-submit">
  29. <?= Html::submitButton($model->isNewRecord ? '创建' : '更新', ['class' => 'btn btn-flat bg-maroon btn-block']) ?>
  30. </div>
  31. <?php ActiveForm::end(); ?>
  32. </div>
  33. </div>
  34. <?php $this->beginBlock('js') ?>
  35. <script>
  36. $(document).on('change', '#choose-editor', function () {
  37. var url = '<?= \yii\helpers\Url::to(['create']) ?>';
  38. var type = $(this).val();
  39. url = url.addQueryParams({editor: type});
  40. location.href = url;
  41. })
  42. </script>
  43. <?php $this->endBlock() ?>