U
U
urfinjazz2015-07-13 18:03:56
Yii
urfinjazz, 2015-07-13 18:03:56

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]">',
]

works
like this:
[
'attribute' => 'name',
'format' => 'raw',
'filter' =>
   function ($model, $index, $widget) {
            return '<input type="text" value="'.$model->name.'"
              placeholder="название книги" class="form-control" name="BooksSearch[name]">';
          },
 ]

doesn't work
3) How to add first (which is empty) option to dropdown-list?
looks like that:
[
'attribute' => 'author_id',
'value' => 'author.fullname',
'filter' => $authors_list
],

an empty field is always added to the beginning, no matter what I do
PS There are 4 more questions that could not be implemented at all:
is it possible to do a search in the GridView after clicking on the button, and not on the blur?
Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
LAV45, 2015-07-14
@LAV45

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,
            ]
        ]
    ]
]);

3) DataColumn itself adds it there
https://github.com/yiisoft/yii2/blob/master/framew...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question