Please can someone explain how the search method in a Yii2 SearchModel works? I generated it using Gii. Here it is:
public function
The search() function generated by Gii use ActiveRecord::load() to set search parameters :
load()gets the'FormName'from the model'sformName()method (which you may override), unless the$formNameparameter is given. If the form name is empty,load()populates the model with the whole of$data, instead of$data['FormName'].
So you should try :
$myModels = $search->search(['MyModelSearch'=>['att3'=>3]]);
Or
$myModels = $search->search([$search->formName()=>['att3'=>3]]);
And of course add a condition on att3 attribute in search() function :
$this->addCondition($query, 'att3');
But if you really want to use $myModels = $search->search(['att3' => '3']); then you should simply replace $this->load($params) with $this->load($params, '').