M
M
Monitorkin2016-02-11 12:52:17
Yii
Monitorkin, 2016-02-11 12:52:17

How to write an arbitrary value in _form.php?

There is a form _form.php, it has all sorts of fields:

<?php $form = ActiveForm::begin(); ?>
....
<?= $form->field($model, 'create_by')->textInput() ?>
....
// Тут нужно сохранить дату модификации
<?php $model->modified_time = date('Y-m-d H:i:s'); ?>
    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
    </div>
<?php ActiveForm::end(); ?>

I need to store the modification date in the modified_time field, why is it not saved?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex Japson, 2016-02-11
@Monitorkin

Try to create a hidden input with a date like so:

<?= $form->field($model, 'modified_time', [
                    'template' => "{input}"
                ])->hiddenInput(['hidden' => 'hidden', 'value' => date('d.m.Y')])
            ?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question