Answer the question
In order to leave comments, you need to log in
How to drive the date and time in different inputs, but keep everything in one table field?
How to store time in one attribute?
With the help of this widget I enter the date.
<?= $form->field($model, 'srok')->widget(DateControl::className(),
[
'convertFormat' => true,
'type'=>DateControl::FORMAT_DATE,
'displayFormat' => 'php:d M Y',
'saveFormat' => 'php:Y-m-d H:i:s',
'widgetOptions' => [
'pluginOptions' => [
'autoclose' => true,
],
'options' => ['placeholder' => 'Cрок']
],
])->label(false);?>
<div class="col-xs-10">
<?= $form->field($model, 'srok')->textInput(['maxlength' => true, 'placeholder' => 'Время', 'class' => 'inputForm'])->label(false) ?>
</div>
Answer the question
In order to leave comments, you need to log in
DateControl::FORMAT_DATE - date
DateControl::FORMAT_TIME - time
DateControl::FORMAT_DATETIME - date and time
Where did the text unput come from? As I understand it, there should be either 1 widget with DATETIME or 2: one FORMAT_DATE second FORMAT_TIME
If you need to store in one field in the database and you don’t know how to combine, then widgets have nothing to do with it. This is all done in the model in beforSave, for example.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question