_form.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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='Редактировать карточку';
  10. $photo = $model->getPhoto('_cuthd','jpg');
  11. if( $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' => 'Authors[photo]', 'post' => 'cropping', 'aspectRatio' => '1/1']); ?>
  35. </div>
  36. </div>
  37. </div>
  38. <div class="row">
  39. <div class="col">
  40. <?= $form->field($model, 'uid')->textInput(['maxlength' => true]) ?>
  41. <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
  42. <?= $form->field($model, 'url')->textInput(['maxlength' => true]) ?>
  43. <?= $form->field($model, 'jobTitle')->textInput(['maxlength' => true]) ?>
  44. <?= $form->field($model, 'description')->textarea(['maxlength' => true]) ?>
  45. <?= $form->field($model, 'text')->textarea(['maxlength' => true, 'id' => 'text_embed']) ?>
  46. <?= $form->field($model, 'phone')->textInput(['maxlength' => true]) ?>
  47. <?= $form->field($model, 'active')->dropDownList([ 'Y' => 'Y', 'N' => 'N', ], ['prompt' => '']) ?>
  48. <?= $form->field($model, 'show')->dropDownList([ '0' => '0', '1' => '1', ], ['prompt' => '']) ?>
  49. <div class="form-group">
  50. <?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
  51. </div>
  52. </div>
  53. </div>
  54. </div>
  55. <?php ActiveForm::end(); ?>
  56. <?php
  57. $uuid='authors_page';
  58. ?>
  59. <?
  60. $this->registerJs(
  61. <<<JS
  62. $(function () {
  63. console.log($('#text_embed').length);
  64. if($('#text_embed').length != 0){
  65. CKEDITOR.replace('text_embed', {
  66. 'filebrowserBrowseUrl': '/components/admin/ckeditor/kcfinder/browse.php?type=files&uid=$uuid',
  67. 'filebrowserImageBrowseUrl': '/components/admin/ckeditor/kcfinder/browse.php?type=images&uid=$uuid',
  68. 'filebrowserFlashBrowseUrl': '/components/admin/ckeditor/kcfinder/browse.php?type=flash&uid=$uuid',
  69. 'filebrowserUploadUrl': '/components/admin/ckeditor/kcfinder/upload.php?type=files&uid=$uuid',
  70. 'filebrowserImageUploadUrl': '/components/admin/ckeditor/kcfinder/upload.php?type=images&uid=$uuid',
  71. 'filebrowserFlashUploadUrl': '/components/admin/ckeditor/kcfinder/upload.php?type=flash&uid=$uuid',
  72. 'filebrowserAudioBrowseUrl': '/components/admin/ckeditor/kcfinder/browse.php?type=files&uid=$uuid',
  73. 'filebrowserlightboxUploadUrl': '/components/admin/ckeditor/kcfinder/browse.php?type=files&uid=$uuid',
  74. 'height': 400
  75. });
  76. CKEDITOR.on('instanceReady', function(ev) {
  77. ev.editor.on('paste', function(evt) {
  78. evt.data.dataValue = evt.data.dataValue.replace(/[«»]/g,'"');
  79. console.log(evt.data.dataValue);
  80. }, null, null, 9);
  81. });
  82. }
  83. });
  84. JS
  85. ,
  86. View::POS_READY,
  87. 'ck_editor'
  88. );