Answer the question
In order to leave comments, you need to log in
Why are checkboxes cleared when clicked?
It is necessary to arrange filtering on the site beautifully.
Filtering itself works, but .. only within native ActiveForm tags.
I do select or checkboxList - everything works wonderfully and multi-select without reloading the page, only the view of this is terrible.
And if I make a layout of a drop-down list with checkboxes in divs, and just checkboxes in a row - the choice occurs only on the last click + the checkbox "resets" the checked checkbox
of the View:
<?php
$this->registerJs(
'$("document").ready(function(){
$(document).on("change", "label", function(e) {
e.preventDefault();
$("#filter-form").submit();
});
});'
);
?>
<div class="shop-new col-md-12 animated bounceInLeft">
<h1>
New
</h1>
<div class="col-md-12 filters-menu-section">
</div>
<?php Pjax::begin([
'id' => 'productList',
'enablePushState' => false,
'enableReplaceState' => false,
]); ?>
<?php $form = ActiveForm::begin([
'id' => 'filter-form',
'action' => ['new'],
'method' => 'get',
'options' => ['data-pjax' => true],
]); ?>
<div class="new-sortFilter-nav status_chk">
<?php echo $this->render('_search', ['model' => $searchModel]); ?>
</div>
<?php ActiveForm::end(); ?>
<?= $this->render('_loop', ['dataProvider' => $dataProvider, 'searchModel' => $searchModel]); ?>
<?php Pjax::end(); ?>
</div>
<div class="product-search">
<?php $form = ActiveForm::begin([
'id' => 'filter-form',
'action' => 'search',
'method' => 'get',
]); ?>
<?= $form->field($model, 'category_id')->checkboxList(Category::find()->select(['title', 'id'])->indexBy('id')->column()) ?>
<?php // echo $form->field($model, 'price') ?>
<?php // echo $form->field($model, 'new') ?>
<?php // echo $form->field($model, 'hit') ?>
<?php // echo $form->field($model, 'sale') ?>
<?php ActiveForm::end(); ?>
</div>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question