_form.php 1.39 KB
<?php
    
    use noam148\imagemanager\components\ImageManagerInputWidget;
    use yii\helpers\Html;
    use yii\web\View;
    use yii\widgets\ActiveForm;
    
    /**
     * @var View                  $this
     * @var \common\models\Slider $model
     * @var ActiveForm            $form
     */
?>

<div class="slider-form">
    
    <?php $form = ActiveForm::begin(); ?>
    
    <?= $form->field($model, 'image_id')
             ->widget(
                 ImageManagerInputWidget::className(),
                 [
                     'aspectRatio'                  => ( 16 / 9 ),
                     //set the aspect ratio
                     'showPreview'                  => true,
                     //false to hide the preview
                     'showDeletePickedImageConfirm' => false,
                     //on true show warning before detach image
                 ]
             ) ?>
    
    <?= $form->field($model, 'link')
             ->textInput() ?>
    
    <?= $form->field($model, 'sort')
             ->input('number') ?>
    
    <?= $form->field($model, 'status')
             ->checkbox([ 'class' => 'flat', ]) ?>
  
  <div class="form-group">
      <?= Html::submitButton(
          $model->isNewRecord ? 'Создать' : 'Обновить',
          [ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]
      ) ?>
  </div>
    
    <?php ActiveForm::end(); ?>

</div>