<div class="mb-3">
<div class="d-flex justify-content-between">
<?= $formFilter->field($filter, 'date_from', ['options' => ['class' => 'w-100']])
- ->dropDownList($months, ['prompt' => 'Выбрать дату от', 'id' => 'filter-date-from'])
+ ->dropDownList($months,
+ [
+ 'prompt' => 'Выбрать дату от',
+ 'id' => 'filter-date-from',
+ 'class' => ''
+ ]
+ )
->label(false) ?>
<div class="mb-4 ms-1 d-flex justify-content-center align-items-center clear-btn" data-target="filter-date-from" >
<i class="fa fa-times"></i>
<div>
<div class="d-flex justify-content-between">
<?= $formFilter->field($filter, 'date_to', ['options' => ['class' => 'w-100']])
- ->dropDownList($months, ['prompt' => 'Выбрать дату до', 'id' => 'filter-date-to'])
+ ->dropDownList($months,
+ [
+ 'prompt' => 'Выбрать дату до',
+ 'id' => 'filter-date-to',
+ 'class' => ''
+ ]
+ )
->label(false) ?>
<div class="mb-4 ms-1 d-flex justify-content-center align-items-center clear-btn" data-target="filter-date-to" >
<i class="fa fa-times"></i>
return Html::hiddenInput("actuality[$i][guid]", $m->id)
. Html::tag('div',
Html::dropDownList("actuality[$i][from]", $from, $months, [
- 'class'=>'form-select form-select-sm me-1',
+ 'class'=>'form-select from-month form-select-sm me-1',
'prompt'=>'от'
])
. Html::dropDownList("actuality[$i][to]", $to, $months, [
- 'class'=>'form-select form-select-sm',
+ 'class'=>'form-select to-month form-select-sm',
'prompt'=>'до'
]),
['class'=>'d-flex align-items-center']
to.val(from);
}
});
+
+ $('#filter-date-from').on('change', function(){
+ var from = $(this).val();
+ var to = $('#filter-date-to');
+ to.find('option').each(function(){
+ var val = $(this).val();
+ if (val === '' || val >= from) {
+ $(this).show();
+ } else {
+ $(this).hide();
+ }
+ });
+ if (to.val() && to.val() < from) {
+ to.val(from);
+ }
+ });
$('.clear-btn').on('click', function(){
var target = $(this).data('target');
$('#' + target).val(null).trigger('change');