Answer the question
In order to leave comments, you need to log in
How to filter records in model before displaying index?
Good day everyone. The question is related to the question How to store and process similar entities (for example, planned and actual transactions)?
Records of two (possibly more) types of records are stored in one table.
The type is stored in the type column.
I made two menu items with the type parameter, which is passed via a get request.
I checked that the controller receives this parameter in actionIndex.
I tried to add a condition to ModelSearch - it did not help: the ['type'] parameter came in the $params variable, but after $this->load($params) it was reset to zero.
Can you please tell me how to filter the values in the model (before displaying in the GridView) by the type parameter? Those. when no filters are being passed yet.
Answer the question
In order to leave comments, you need to log in
Any model in the load method expects an array of type:
[
// имя класса без неймспейса
'ModelSearch' => [
...
]
]
if (!$modelSearch->type) {
$modelSearch->type = 'булехум!';
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question