view.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. use yii\helpers\Html;
  3. use yii\widgets\ActiveForm;
  4. use app\widgets\CropperjsWidget;
  5. use yii\web\View;
  6. /** @var yii\web\View $this */
  7. /** @var app\models\Authors $model */
  8. /** @var yii\widgets\ActiveForm $form */
  9. $this->title='Редактировать карточку '.$model->getProfile()->one()->name;
  10. $photo = "/".$obj::$story_dir."/".$model->id."_norm.jpg";
  11. if( file_exists( Yii::getAlias('@webroot').$photo ) ){
  12. $imageSrc = $photo."?r=".rand();
  13. }else{
  14. $imageSrc = '/img/e.gif';
  15. }
  16. ?>
  17. <style>
  18. #image {
  19. width: 420px;
  20. background: URL(/img/image.svg) no-repeat 50% 50%;
  21. background-size: contain;
  22. background-color: #fff;
  23. cursor: pointer;
  24. aspect-ratio: 1/1;
  25. background-size: 70%;
  26. }
  27. </style>
  28. <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]) ?>
  29. <div class="container-fluid authors-form">
  30. <div class="row">
  31. <div class="col-6 col-sm-6">
  32. <div class="input-group mb-3">
  33. <img id="image" class="img-circle elevation-2" src="<?=$imageSrc?>" onClick="$('#modal').modal('show');document.getElementById('inputImage').click();" >
  34. <? echo CropperjsWidget::widget(['image' => 'image', 'file' => 'User[photo]', 'post' => 'cropping', 'aspectRatio' => '1/1']); ?>
  35. </div>
  36. </div>
  37. </div>
  38. <div class="row">
  39. <div class="col">
  40. <div class="form-group">
  41. <?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
  42. </div>
  43. </div>
  44. </div>
  45. </div>
  46. <?php ActiveForm::end(); ?>