S
S
shanik2017-09-25 16:03:09
Yii
shanik, 2017-09-25 16:03:09

Why is search not working in gridVew Yii2?

There is a GridView which is in between :

<?php $f = ActiveForm::begin
  ....
  endForm?>

When searching by column, redirects to the form action. If the GridView is not done inside the form, then everything works. How to win it?
public function search($id = null,$floraTaxonId = null,$params)
    {
        $query = Taxon::find();

        // add conditions that should always apply here

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        ]);

        $this->load($params);

        // grid filtering conditions
        $query->andFilterWhere([
            'id' => $this->id,
            'rang_id' => $this->rang_id,
        ]);

        $query->andFilterWhere(['like', 'name', $this->name])
            ->andFilterWhere(['like', 'hybrid', $this->hybrid])
            ->andFilterWhere(['like', 'literature', $this->literature])
            ->andFilterWhere(['like', 'habitat', $this->habitat]);

        return $dataProvider;
    }

Parameter passedYii::$app->request->queryParams

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2017-09-25
@slo_nik

Here is my answer to a similar question.
So you can get the desired id.
You just have to send the data to the server using ajax and write it to the database there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question