Closed ghost closed 6 years ago
Debug your code and your data. You should have a valid date value of the correct format set in your 2 range attributes. The format must match the plugin format set. Else your date range will get broken.
Same problem. It raises only if startAttribute
and endAttribute
setted and it concatenates two empty strings with separator
@sebascar if you're using your widget without a model you can simply insert 'locale' to your pluginOptions configuration like this:
'pluginOptions' => [ 'locale' => [ 'format' => 'd-m-Y' ], ],
If then you use a model and startAttribute/endAttribute are propeties (field) of that model you can resolve this issue with the DateRangeBehavior.
`
public $createTimeRange;
public $createTimeStart;
public $createTimeEnd;
/**
* @inheritdoc
*/
public function behaviors()
{
return [
[
'class' => DateRangeBehavior::className(),
'attribute' => 'createTimeRange',
'dateStartAttribute' => 'createTimeStart',
'dateEndAttribute' => 'createTimeEnd',
'dateStartFormat' => 'Y-m-d',
'dateEndFormat' => 'Y-m-d'
],
];
}`
this should resolve your issue
This is an example code:
echo DateRangePicker::widget([ 'name' => 'date_range', 'attribute' => 'datetime_range', 'startAttribute' => 'startDate', 'endAttribute' => 'endDate' ]);
If both startAttribute and endAttribute are set then the picker goes nuts: