Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New feature for the issue #551 #552

Merged
merged 4 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading