zubzizub
7/28/2017 - 1:03 PM

active form example

active form example

 <?php $form = ActiveForm::begin([
        'options' => [
            'enctype' => 'multipart/form-data',
            'type'=>'post',
        ],

    ]); ?>

    <?= $form->field($model, 'slider_id')->hiddenInput(['value'=> $sliderId])->label(false); ?>

    <?= $form->field($model, 'link')->textInput(['style'=>'width:40%;']) ?>

    <?= $form->field($model, 'text')->label('Описание')->widget(CKEditor::className(), [
        'options' => ['rows' => 3],
        'preset' => 'full'
    ]) ?>

    <?= $form->field($model, 'sort_order')->textInput(['style'=>'width:10%;'])->label('Сортировка') ?>

    <?= $form->field($model, 'active')->dropDownList([0 => 'Нет', 1 => 'Да'],['style'=>'width:10%;']) ?>

    <?php
    $img = Html::img($model->getAttribute('image'), ['class' => 'image-column']);
    echo '<div id="slides-grid">' . $img . '</div>';
    ?>

    <section style="display: block" type="x-tmpl-underscore" id="image-upload-template">
        <input type="hidden" name="slide_id" value="<?= $model->id ?>">
        <input type="hidden" name="attribute" value="image">
        <input type="hidden" name="slider_id" value="<?= $sliderId ?>">
        <div class="form-group">
            <label><?= Yii::t('app', 'New image') ?></label>
            <input type="file" name="file">
        </div>
    </section>

    <div class="form-group">
        <?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
    </div>

    <?php ActiveForm::end(); ?>