test.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. use yii\helpers\Html;
  3. use yii\widgets\ActiveForm;
  4. use app\widgets\CropperjsWidget;
  5. $newsDataProvider = new \yii\data\ActiveDataProvider(
  6. [
  7. "query"=>\app\models\Kd::find()->andWhere(['>','order',2])->orderBy(["order"=>SORT_ASC])->limit(2),
  8. "pagination" => false
  9. ]
  10. );
  11. $sort = $newsDataProvider->getModels();
  12. //print_r($sort);
  13. $ActiveNews = new \yii\data\ActiveDataProvider();
  14. $models = [];
  15. //$models[] = \app\models\News::findOne($NH[0]->id);
  16. foreach( $sort as $item ){
  17. $models[] = \app\models\News::findOne($item->id);
  18. }
  19. $ActiveNews->setModels($models);
  20. print_r($ActiveNews);
  21. print_r($_POST);
  22. $form = ActiveForm::begin([
  23. 'id' => 'test-form',
  24. 'options' => ['class' => 'form-horizontal', 'enctype' => 'multipart/form-data']]);
  25. ?>
  26. <input type="hidden" name="test[id]" value="test">
  27. <style>
  28. #image {
  29. width: 300px;
  30. min-height: 150px;
  31. background: URL(/img/image.svg) no-repeat 50% 50%;
  32. background-size: contain;
  33. background-color: #fff;
  34. cursor: pointer;
  35. }
  36. </style>
  37. <img id="image" src="/img/e.gif" onClick="function(){$('#modal').modal('show');$('#inputImage').click();}">
  38. <?
  39. echo CropperjsWidget::widget(['image' => 'image', 'file' => 'photo', 'post' => 'cropping']);
  40. echo Html::submitButton('Send', ['class' => 'btn btn-success']);
  41. ActiveForm::end();