Answer the question
In order to leave comments, you need to log in
How to bind values from DateRangePicker to model variables?
Available model
class PlotCreation extends \yii\base\Model
{
public $date_from;
public $date_to;
...
}
echo DateRangePicker::widget([
'name' => 'date_range',
'value' => '2017-05-02 01:00:00 PM - 2017-05-03 01:00:00 PM',
'convertFormat' => true,
'pluginOptions' => [
'timePicker' => true,
'timePickerIncrement' => 10,
'locale' => ['format' => 'Y-m-d h:i:s']
]
]);
Answer the question
In order to leave comments, you need to log in
The documentation says:
startAttribute : string, the attribute name which you can set optionally to track changes to the range start value. One of the following actions will be taken when this is set:
If using with model, an active hidden input will be automatically generated using this as an attribute name for the start value of the range.
endAttribute : string, the attribute name which you can set optionally to track changes to the range end value. One of the following actions will be taken when this is set:
If using with model, an active hidden input will be automatically generated using this as an attribute name for the end value of the range.
Example from the docs :
$model->datetime_start = '2016-02-11';
$model->datetime_end = '2016-03-15';
echo '<div class="input-group drp-container">';
echo DateRangePicker::widget([
'model'=>$model,
'attribute' => 'kvdate1',
'useWithAddon'=>true,
'convertFormat'=>true,
'startAttribute' => 'datetime_start',
'endAttribute' => 'datetime_end',
'pluginOptions'=>[
'locale'=>['format' => 'Y-m-d'],
]
]) . $addon;
echo '</div>';
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question