Skip to content

Commit

Permalink
Fix #551: Add optional parameter $formName to `SearchModel::search(…
Browse files Browse the repository at this point in the history
…)` method
  • Loading branch information
evil1 authored Dec 26, 2024
1 parent c025c29 commit 3e270e1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Yii Framework 2 gii extension Change Log

2.2.7 under development
-----------------------

- Enh #551: Add optional parameter `$formName` to `SearchModel::search()` method (evil1)
- Bug #531: Fix `yii\gii\console\GenerateAction` to use `stdout()` instead of echoing the output (egmsystems)
- Bug #532: Return `ExitCode::USAGE` on command input validation error (egmsystems)
- Enh #537: Generating rules for the fields with default values (manky)
Expand Down
5 changes: 3 additions & 2 deletions src/generators/crud/default/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@ public function scenarios()
* Creates data provider instance with search query applied
*
* @param array $params
* @param string $formName Form name to be used into `->load()` method. By default it is equal to the class name.
*
* @return ActiveDataProvider
*/
public function search($params)
public function search($params, $formName = '<?= $searchModelClass ?>')
{
$query = <?= isset($modelAlias) ? $modelAlias : $modelClass ?>::find();

Expand All @@ -70,7 +71,7 @@ public function search($params)
'query' => $query,
]);

$this->load($params);
$this->load($params, $formName);

if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
Expand Down

0 comments on commit 3e270e1

Please sign in to comment.