title: Yii2 - DetailView Search box
body: <p><strong>I have this action inside ProdutosController. It renders view2 that has an itemview pointing to _view2 which has a DetailView to show products.</strong></p>
  
  <pre><code>public function actionView2()
  {   
      $model = new Produtos();
      $dataProvider = new ActiveDataProvider([
      'query' =&gt; Produtos::find(),
      'pagination' =&gt; false,
      ]);
  
      // get the posts in the current page
      $posts = $dataProvider-&gt;getModels();
  
      // render
      return $this-&gt;render('view2', [
          'dataProvider' =&gt; $dataProvider,
          'model' =&gt; $model,
      ]);
  }
  </code></pre>
  
  <p><strong>the view2</strong></p>
  
  <pre><code>&lt;?php
  
  use yii\helpers\Html;
  use yii\widgets\ListView;
  use yii\helpers\Url;
  
  /* @var $this yii\web\View */
  /* @var $model app\models\Atividades */
  
  // $this-&gt;title = implode('', $cat);
  ?&gt;
  &lt;div class="produtos-view2"&gt;
      &lt;?php
      //use kartik\social\FacebookPlugin;
      //echo FacebookPlugin::widget(['type'=&gt;FacebookPlugin::SHARE, 'settings' `=&gt; []]);`
      ?&gt;
  &lt;/div&gt;
  
  &lt;?= ListView::widget([
      'dataProvider' =&gt; $dataProvider,
      'itemView' =&gt; '_view2',
  ]); ?&gt;
  
  &lt;br/&gt;&lt;br/&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>and the _view2 that as DetailView inside:</strong></p>
  
  <pre><code>&lt;?= DetailView::widget([
      'model' =&gt; $model,
      'options' =&gt; ['class' =&gt; 'detail1-galeria-view2'],
      'attributes' =&gt; [
          // cria um array com a fotografia, em que carrega a path no campo fieldName da bd
          [
              'attribute'=&gt;'',
              //'value'=&gt;$model-&gt;foto,
              'value'=&gt;Html::a(Html::img(Yii::$app-&gt;getUrlManager()-&gt;getBaseUrl() . "/" .$model-&gt;foto, ['width'=&gt;'192', 'height' =&gt; "256"]), $model-&gt;foto),
              'format' =&gt; 'raw',
          ],
          [
          'attribute'=&gt;'',
          'value'=&gt;$model-&gt;nome,
          ],
          [
          'attribute'=&gt;'',
          'value'=&gt;$model-&gt;categoria,
          ],
          [
          'attribute'=&gt;'',
          'value'=&gt;$model-&gt;descricao,
          ],
          [
          'attribute'=&gt;'',
          'value'=&gt;$model-&gt;valor.' '.'€',
          ],
          // info
          [
          'attribute'=&gt;'',
          'format' =&gt; 'raw',
          'value'=&gt; Html::a(Yii::t('app','Comprar'), Url::toRoute(['contacto/create2'])),
          ],
      ],
  ]) ?&gt;
  </code></pre>
  
  <p>In another project i was able to make a search box in _view2 by render _search.php inside it and by modifying the ProdutosSearch model. But this was achieved with a GridView that accepts $dataprovider and $searchModel directly inside the widget.</p>
  
  <p><strong>Now in my new project, i'm trying hard to make a search input box to filter what the DetailView shows (it shows the foto, name, category, etc... of products) but cannot do it because the detail view doesn't accept $dataProvider data.</strong></p>
  
  <p>How can i solve this and make a products gallery with search box using a <strong>DetailView</strong>.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Controller action:</p>
  
  <pre><code>public function actionMySearchFunction()
  {   
      $model = new Produtos();
      $searchModel = new CategoriasSearch();
      $dataProvider = $searchModel-&gt;search(Yii::$app-&gt;request-&gt;queryParams);
      $dataProvider = new ActiveDataProvider([
      'query' =&gt; Produtos::find(),
      'pagination' =&gt; false,
      ]);
  
      // get the posts in the current page
      $posts = $dataProvider-&gt;getModels();
  
      // render
      return $this-&gt;render('view2', [
          'dataProvider' =&gt; $dataProvider,
          'searchModel' =&gt; $searchModel,
          'model' =&gt; $model,
      ]);
  }
  </code></pre>
  
  <p><strong>MySearchFunction.php</strong></p>
  
  <pre><code>&lt;?php
  public function MySearchFunction()
  
  {
  $post = Yii::$app-&gt;request-&gt;post(); 
  
  if (!empty($post)){
  
      $postParam1 = $post['categoria']; // get the value ffrom the filter field submitted) 
  
      $query = ProdutosSearch::find()-&gt;where(['categoria' =&gt;  $postParam1]);
  
      $dataProvider = new \yii\data\ActiveDataProvider([
          'query' =&gt; $query,
      ]);
  
      $dataProvider-&gt;pagination-&gt;pageSize=15;
  
      return $this-&gt;render('view2', [
          'dataProvider' =&gt; $dataProvider,
      ]);
  
  }
  </code></pre>
  
  <p>}
  ?></p>
  
  <p><strong>VIEW2</strong></p>
  
  <pre><code>&lt;?php $form = ActiveForm::begin([
      'action' =&gt; Url::to(['/produtos/my-search-function']),
      'method' =&gt; 'get',
      'options' =&gt; ['class' =&gt; 'form-inline form-group form-group-sm col-xs-12'],
      'fieldConfig' =&gt; [
          'template' =&gt; "{input}",
      ],
  ]); ?&gt;
  &lt;/div&gt;
  &lt;?php echo var_dump(Url::to(['/produtos/my-search-function'])); ?&gt;
  
  &lt;!--&lt;nobr&gt;&lt;?= $form-&gt;field($model, 'nome')-&gt;textInput(['placeholder' =&gt; 'Nome']) ?&gt;--&gt;
  
  &lt;nobr&gt;
      &lt;?= $form-&gt;field($searchModel, 'categoria')-&gt;dropDownList(ArrayHelper::map(Categorias::find()-&gt;all(), 'categoria','categoria'), ['prompt'=&gt;Yii::t('yii', 'Escolha a categoria...')])  ?&gt;
      &lt;?= Html::submitButton(Yii::t('app', 'Pesquisar'), ['class' =&gt; 'btn btn-warning']) ?&gt;
  &lt;/nobr&gt;
  &lt;?php ActiveForm::end(); ?&gt;
  
  &lt;div class="user-view"&gt;
  
      &lt;?= ListView::widget([
          'dataProvider' =&gt; $dataProvider,
          'itemView' =&gt; '_view2',
      ]); ?&gt;
  
      &lt;br/&gt;&lt;br/&gt;
  
  &lt;/div&gt;
  </code></pre>