_form.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. use yii\helpers\Html;
  3. use yii\widgets\ActiveForm;
  4. use yii\web\View;
  5. use app\widgets\CropperjsWidget;
  6. /** @var yii\web\View $this */
  7. /** @var app\models\Person $model */
  8. /** @var yii\widgets\ActiveForm $form */
  9. $uuid = 'persone_page';
  10. @session_start();
  11. $_SESSION['KCFINDER']['admin_news'] = true;
  12. // CKEditor
  13. $this->registerJs(
  14. <<<JS
  15. CKEDITOR.replace('Person[description]', {
  16. 'filebrowserBrowseUrl': '/components/admin/ckeditor/kcfinder/browse.php?type=files&uid=$uuid',
  17. 'filebrowserImageBrowseUrl': '/components/admin/ckeditor/kcfinder/browse.php?type=images&uid=$uuid',
  18. 'filebrowserFlashBrowseUrl': '/components/admin/ckeditor/kcfinder/browse.php?type=flash&uid=$uuid',
  19. 'filebrowserUploadUrl': '/components/admin/ckeditor/kcfinder/upload.php?type=files&uid=$uuid',
  20. 'filebrowserImageUploadUrl': '/components/admin/ckeditor/kcfinder/upload.php?type=images&uid=$uuid',
  21. 'filebrowserFlashUploadUrl': '/components/admin/ckeditor/kcfinder/upload.php?type=flash&uid=$uuid',
  22. 'filebrowserAudioBrowseUrl': '/components/admin/ckeditor/kcfinder/browse.php?type=files&uid=$uuid',
  23. 'filebrowserlightboxUploadUrl': '/components/admin/ckeditor/kcfinder/browse.php?type=files&uid=$uuid',
  24. 'height': 400
  25. });
  26. JS
  27. ,
  28. View::POS_READY,
  29. 'ck_editor'
  30. );
  31. if($model->id){
  32. $imageSrc = $model->getImg('hd','jpg')."?r=".rand();
  33. }else{
  34. $imageSrc = '/img/e.gif';
  35. }
  36. ?>
  37. <style>
  38. #image {
  39. width: 100%;
  40. aspect-ratio: 16/9;
  41. background: URL(/img/image.svg) no-repeat 50% 50%;
  42. background-size: contain;
  43. background-color: #fff;
  44. cursor: pointer;
  45. margin: 10px;
  46. }
  47. </style>
  48. <div class="person-form">
  49. <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?>
  50. <?= $form->field($model, 'name')->textInput() ?>
  51. <div style="width:30%;">
  52. <img id="image" src="<?=$imageSrc?>" onClick="$('#modal').modal('show');document.getElementById('inputImage').click();" >
  53. </div>
  54. <?
  55. echo CropperjsWidget::widget(['image' => 'image', 'file' => 'Person[photo]', 'post' => 'cropping', 'aspectRatio' => '16 / 9']);
  56. ?>
  57. <?= $form->field($model, 'alias')->textInput([
  58. 'maxlength' => true,
  59. 'class' => 'form-control js-word-count-input',
  60. 'placeholder' => 'URL если не заполнить, то создаётся из имини'
  61. ])->label('URL часть адреса рездела');
  62. ?>
  63. <?= $form->field($model, 'jobtitle')->textarea(['rows' => 2]) ?>
  64. <?= $form->field($model, 'birthdate')->widget(\yii\jui\DatePicker::className(), [ 'dateFormat' => 'dd-MM-yyyy', 'options' => ['class' => 'form-control', 'placeholder' => 'День рождения персоны (если неизвестно - не заполнять)', 'id'=>'birthdate']]) ?>
  65. <?= $form->field($model, 'description')->textarea(['rows' => 6]) ?>
  66. <?= $form->field($model, 'phone')->textInput()->label('<i class="fas fa-lg fa-phone"></i> Телефон'); ?>
  67. <?= $form->field($model, 'email')->textInput() ?>
  68. <div class="form-group ml-5">
  69. <?= $form->field($model, 'show')->checkbox([
  70. 'uncheck' => 'N',
  71. 'class' => 'form-check-input',
  72. 'checked' => ($model->show == 'Y')?true:false,
  73. 'label' =>'Показывать'
  74. ]);
  75. ?>
  76. </div>
  77. <div class="form-group">
  78. <?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
  79. </div>
  80. <?php ActiveForm::end(); ?>
  81. </div>