Form do Yii

Boa tarde pessoal, fui realizar uma consulta na minha view de outra tabela mas o botão de pesquisa do search sumiu, como posso recuperar este botão de pesquisa do form? E se é realmente neste arquivo _search.

Estou me referindo aqueles campos de filtro que ficam abaixo do título dos campos na grid.

######### View ##########

[

‘attribute’ => ‘Data’,

  'content' => function(SaleItems $model, $key, $index, $column) {


   return $model->sale->date;


   },

],

######### _search ##########

<div class="sale-items-search">

&lt;?php &#036;form = ActiveForm::begin([


    'action' =&gt; ['index'],


    'method' =&gt; 'get',


]); ?&gt;











&lt;?= &#036;form-&gt;field(&#036;model, 'Data') ?&gt;








&lt;div class=&quot;form-group&quot;&gt;


    &lt;?= Html::submitButton('Search', ['class' =&gt; 'btn btn-primary']) ?&gt;


    &lt;?= Html::resetButton('Reset', ['class' =&gt; 'btn btn-default']) ?&gt;


&lt;/div&gt;





&lt;?php ActiveForm::end(); ?&gt;

</div>

Hi,

I would like to help you but i don’t understand the language you write. Try write in English you will have more answers.

@santosilva, vc quer hablitar novamente a pesquisa da grid da index?

Se for isso basta adicionar ‘filterModel’ => $searchModel, no seu widget.


<?= GridView::widget([

        'dataProvider' => $dataProvider,

        'filterModel' => $searchModel,

        'columns' => [

            ['class' => 'yii\grid\SerialColumn'],

Bom dia @Cálcio, já tem, o negócio foi quando eu fui adicionar um campo de outra tabela. No atribulo Data.

&lt;?php





use app&#092;models&#092;SaleItems;


use yii&#092;helpers&#092;Html;


use yii&#092;grid&#092;GridView;





/* @var &#036;this yii&#092;web&#092;View */


/* @var &#036;searchModel app&#092;models&#092;SaleItemsSearch */


/* @var &#036;dataProvider yii&#092;data&#092;ActiveDataProvider */





&#036;this-&gt;title = 'Controle de Entradas e Saídas';


&#036;this-&gt;params['breadcrumbs'][] = &#036;this-&gt;title;


?&gt;


&lt;div class=&quot;sale-items-index&quot;&gt;





    &lt;h1&gt;&lt;?= Html::encode(&#036;this-&gt;title) ?&gt;&lt;/h1&gt;


    &lt;?php  ?&gt;


    &lt;?php // echo &#036;this-&gt;render('_search', ['model' =&gt; &#036;searchModel]); ?&gt;








    &lt;?= GridView::widget([


        'dataProvider' =&gt; &#036;dataProvider,


        'filterModel' =&gt; &#036;searchModel,


        'columns' =&gt; [


            ['class' =&gt; 'yii&#092;grid&#092;SerialColumn'],





            [


            'attribute' =&gt; 'Data',


                'content' =&gt; function(SaleItems &#036;model, &#036;key, &#036;index, &#036;column) {


                    return date('d/m/Y', strtotime(&#036;model-&gt;sale-&gt;date));


                    },


                'header' =&gt; 'DATA'


            ],





            [


                'attribute' =&gt; 'product_name',


                'header' =&gt; 'PRODUTOS'


            ],





            [


                'attribute' =&gt; 'quantity',


                'header' =&gt; 'QUANTIDADE VENDIDA'


            ],





            [


            'attribute' =&gt; 'gross_total',


                'header' =&gt; 'ENTRADAS'


            ],





            ['attribute' =&gt; 'gross_total',


            'header' =&gt; 'SAÍDAS'


            ],


            ['class' =&gt; 'yii&#092;grid&#092;ActionColumn'],


        ],





    ]); ?&gt;





&lt;/div&gt;

I perform a query in My vision of Another table but the search button the search for disappeared , How Can I Recover this search button form ? And See and really this _search File.

<?php

use app\models\SaleItems;

use yii\helpers\Html;

use yii\grid\GridView;

/* @var $this yii\web\View */

/* @var $searchModel app\models\SaleItemsSearch */

/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = ‘Controle de Entradas e Saídas’;

$this->params[‘breadcrumbs’][] = $this->title;

?>

<div class="sale-items-index">

<h1><?= Html::encode($this->title) ?></h1>

<?php ?>

<?php // echo $this->render(’_search’, [‘model’ => $searchModel]); ?>

<?= GridView::widget([

‘dataProvider’ => $dataProvider,

‘filterModel’ => $searchModel,

‘columns’ => [

[‘class’ => ‘yii\grid\SerialColumn’],

[

‘attribute’ => ‘Data’,

‘content’ => function(SaleItems $model, $key, $index, $column) {

return date(‘d/m/Y’, strtotime($model->sale->date));

},

‘header’ => ‘DATA’

],

[

‘attribute’ => ‘product_name’,

‘header’ => ‘PRODUTOS’

],

[

‘attribute’ => ‘quantity’,

‘header’ => ‘QUANTIDADE VENDIDA’

],

[

‘attribute’ => ‘gross_total’,

‘header’ => ‘ENTRADAS’

],

[‘attribute’ => ‘gross_total’,

‘header’ => ‘SAÍDAS’

],

[‘class’ => ‘yii\grid\ActionColumn’],

],

]); ?>

</div>