Issue
I have two tables "attendance" with attributes id
, status
, date
and "staff". staff_id
is used as foreign key in attendance table. In _form.php of attendance I used
<?= $form->field($model, 'status')->dropDownList([ 'Present' => 'Present', 'Absent' => 'Absent', 'Leave' => 'Leave',], ['prompt' => 'Select status']) ?>
for dropdown. Now I want to a dropdown in gridview search columns with property of filtering and searching. I would like my gridview to be filtered by the dropdown list I have. So when I choose a value from the dropdown list, it should search on base of choosed value. Any help would be highly appriciated.
Solution
I think your question is about status field
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
........
[
'attribute' => 'status',
'label' => 'Status',
'filter' => [ 'Present' => 'Present', 'Absent' => 'Absent', 'Leave' => 'Leave',]
],
......
Answered By - ScaisEdge
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.