{"action":"created","issue":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/8221","labels_url":"https://api.github.com/repos/yiisoft/yii2/issues/8221/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii2/issues/8221/comments","events_url":"https://api.github.com/repos/yiisoft/yii2/issues/8221/events","html_url":"https://github.com/yiisoft/yii2/issues/8221","id":71837860,"number":8221,"title":"GET request to /app/model/PostSearch::search()","user":{"login":"louisseb","id":4997902,"avatar_url":"https://avatars.githubusercontent.com/u/4997902?v=3","gravatar_id":"","url":"https://api.github.com/users/louisseb","html_url":"https://github.com/louisseb","followers_url":"https://api.github.com/users/louisseb/followers","following_url":"https://api.github.com/users/louisseb/following{/other_user}","gists_url":"https://api.github.com/users/louisseb/gists{/gist_id}","starred_url":"https://api.github.com/users/louisseb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/louisseb/subscriptions","organizations_url":"https://api.github.com/users/louisseb/orgs","repos_url":"https://api.github.com/users/louisseb/repos","events_url":"https://api.github.com/users/louisseb/events{/privacy}","received_events_url":"https://api.github.com/users/louisseb/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-04-29T10:25:30Z","updated_at":"2015-05-18T10:33:47Z","closed_at":"2015-05-18T10:33:47Z","body":"When calling  /app/model/ModelSearch::search() from a form (post request), the form datas are loaded via /yii/base/Model::load($params, $formName). The data are inside the array $params['ModelSearch'] , and they are parsed inside the search object thanks to $this->setAttributes($data[$scope]).\r\n\r\nBut, when calling  /app/model/ModelSearch::search() from an url (a GET request), the params datas can't be loaded, because they are not inside a table  $params['ModelSearch'], but directly inside $params.\r\n\r\nThe load function accept a second parameter for this case : $formName, wich if empty, call $this->setAttributes($data). BUT, the logic of /app/model/ModelSearch::search() , as generated by GII, don't give any way to provide this second parameter to the load function. \r\n\r\nHere what it does :\r\n\r\npublic function search($params)\r\n{\r\n...\r\n   $this->load($params);\r\n}\r\n\r\nThe /app/model/ModelSearch::search() should accept a second parameter to parse to load function, or should check $params['ModelSearch'] is empty.\r\n\r\n\r\nHere the fix I propose :\r\n\r\npublic function search($params)\r\n{\r\n...\r\n  if(isset$params['ModelSearch'])\r\n   {\r\n      $this->load($params);\r\n   }\r\n   else\r\n   {\r\n     $this->load($params, '');\r\n   }\r\n\r\n}"},"comment":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/comments/103011624","html_url":"https://github.com/yiisoft/yii2/issues/8221#issuecomment-103011624","issue_url":"https://api.github.com/repos/yiisoft/yii2/issues/8221","id":103011624,"user":{"login":"klimov-paul","id":1482054,"avatar_url":"https://avatars.githubusercontent.com/u/1482054?v=3","gravatar_id":"","url":"https://api.github.com/users/klimov-paul","html_url":"https://github.com/klimov-paul","followers_url":"https://api.github.com/users/klimov-paul/followers","following_url":"https://api.github.com/users/klimov-paul/following{/other_user}","gists_url":"https://api.github.com/users/klimov-paul/gists{/gist_id}","starred_url":"https://api.github.com/users/klimov-paul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/klimov-paul/subscriptions","organizations_url":"https://api.github.com/users/klimov-paul/orgs","repos_url":"https://api.github.com/users/klimov-paul/repos","events_url":"https://api.github.com/users/klimov-paul/events{/privacy}","received_events_url":"https://api.github.com/users/klimov-paul/received_events","type":"User","site_admin":false},"created_at":"2015-05-18T10:33:47Z","updated_at":"2015-05-18T10:33:47Z","body":"Gii generates only the basic code. If you require additional functionality, you should adjust it yourself or create your own CRUD template."}}