Skip to content

Commit

Permalink
Replace URL parameters dynamically without needing a list in advance …
Browse files Browse the repository at this point in the history
…(#3361)

Fixes #3358. Credit to @jimcottrell
  • Loading branch information
jimcottrell authored and LukeTowers committed Dec 18, 2018
1 parent 54a67ca commit 34da618
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
2 changes: 1 addition & 1 deletion modules/backend/behaviors/FormController.php
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ public function makeRedirect($context = null, $model = null)
}

if ($model && $redirectUrl) {
$redirectUrl = RouterHelper::parseValues($model, array_keys($model->getAttributes()), $redirectUrl);
$redirectUrl = RouterHelper::replaceParameters($model, $redirectUrl);
}

if (starts_with($redirectUrl, 'http://') || starts_with($redirectUrl, 'https://')) {
Expand Down
10 changes: 2 additions & 8 deletions modules/backend/widgets/Lists.php
Original file line number Diff line number Diff line change
Expand Up @@ -631,12 +631,7 @@ public function getRecordUrl($record)
return null;
}

$data = $record->toArray();
$data += [$record->getKeyName() => $record->getKey()];

$columns = array_keys($data);

$url = RouterHelper::parseValues($data, $columns, $this->recordUrl);
$url = RouterHelper::replaceParameters($record, $this->recordUrl);
return Backend::url($url);
}

Expand All @@ -651,8 +646,7 @@ public function getRecordOnClick($record)
return null;
}

$columns = array_keys($record->getAttributes());
$recordOnClick = RouterHelper::parseValues($record, $columns, $this->recordOnClick);
$recordOnClick = RouterHelper::replaceParameters($record, $this->recordOnClick);
return Html::attributes(['onclick' => $recordOnClick]);
}

Expand Down

0 comments on commit 34da618

Please sign in to comment.