tklustig
(Kipp Thomas)
June 16, 2017, 12:27pm
1
Hi guys,
I succesfully implementated kartik-Widget ‘DateTimepicker’ using following Code:
use kartik\datetime\DateTimePicker;
.
.
.
.
<?php
echo '<label>Start Date/Time</label>';
echo DateTimePicker::widget([
'name' => 'dp_2',
'type' => DateTimePicker::TYPE_COMPONENT_PREPEND,
'value' => '01-Jan-2017 10:00',
'pluginOptions' => [
'autoclose'=>true,
'format' => 'dd-M-yyyy hh:ii']]);
?>
<?= $form->field($model, 'zahl_down')->textInput(['value' => $zahl_down])->hint('Die kleinste Zahl,bitte')->label('Zahl(Minimum)') ?>
.
.
.
.
Unfortunately, I have absolutely no idea how to evaluate users choice, 'cause there is no relation to a model. For instance, I evaluate zahl_down like this:
label>Startwert:</label> <?= Html::encode($model->zahl_down) ?><label>...bis...</label></li>
Any ideas how to evaluate DateTimePicker?
tri
(tri - Tommy Riboe)
June 16, 2017, 12:38pm
2
Bind ‘value’ to model->attribute ? (preset the attribute value)
Sorry, I obviously used ‘value’ several years ago (yii 1.1)
Perhaps the ‘attribute’ property
http://www.yiiframework.com/doc-2.0/yii-jui-datepicker.html#$attribute-detail
tklustig
(Kipp Thomas)
June 16, 2017, 1:36pm
3
I found solution in getting help by stackoverflow.First of all,I created some rule:
return ['datetime','string'],....
Furthermore, I refered DatetimePicker to model using following Code:
<?=$form->field($model, 'datetime')->widget(DateTimePicker::className(), [
'type' => DateTimePicker::TYPE_COMPONENT_PREPEND,
'value' => '01-Jan-2017 10:00 AM',
'pluginOptions' =>
[
'autoclose' => false,
'format' => 'dd-M-yyyy HH:ii P'
],
'options' => [
'placeholder' => Yii::t('app', 'Please pick your timepoint'),
],])?>
Now I can evaluate DateTimepicker:
<tr bgcolor="#F3F781">
<td>Ihre Uhrzeit</td>
<td><?php echo $model->datetime;?></td>
</tr>