Answer the question
In order to leave comments, you need to log in
Yii2 GridView: Can you answer questions?
Good afternoon!
I did a test task on Yii2, it seems that it turned out to do what they asked: link
login: admin, password: 123456
But! It turned out to realize some moments well absolutely through one place...
Questions:
1) Is it possible to set zero value for the table? those. display only search field but hide table contents?
2) How to prescribe a placeholder field?
So:
[
'attribute' => 'name',
'format' => 'html',
'filter' =>'<input type="text" placeholder="название книги" class="form-control" name="BooksSearch[name]">',
]
[
'attribute' => 'name',
'format' => 'raw',
'filter' =>
function ($model, $index, $widget) {
return '<input type="text" value="'.$model->name.'"
placeholder="название книги" class="form-control" name="BooksSearch[name]">';
},
]
[
'attribute' => 'author_id',
'value' => 'author.fullname',
'filter' => $authors_list
],
Answer the question
In order to leave comments, you need to log in
2) What does "does not work
"
mean
? yii2/blob/master/framew...
$filter cannot be a callback
, so we add a column not at random or by random method, but according to the description in the class.
GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
[
'attribute' => 'name',
'filterInputOptions' => [
'placeholder' => 'название книги',
'class' => 'form-control',
'id' => null,
]
]
]
]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question