User tests: Successful: Unsuccessful:
Pull Request for Issue # .
This PR adds two new methods, getRedirectUrlToItem() and getRedirectUrlToList(), to the FormController class. These methods centralize the generation of redirection URLs and replace repeated code blocks inside the class.
If accepted, this approach can be extended to child classes of FormController, reducing code duplication and improving maintainability.
Works, but there is repeating code
Cleaner, shorter code and can be used by child classes
Please select:
Documentation link for docs.joomla.org:
No documentation changes for docs.joomla.org needed
Pull Request link for manual.joomla.org:
No documentation changes for manual.joomla.org needed
| Status | New | ⇒ | Pending |
| Category | ⇒ | Libraries |
| Labels |
Added:
PR-6.1-dev
|
||
Yes, Iβm aware of that. However, since AdminController does not extend FormController, there isnβt a straightforward way to share these methods between them. One alternative would be to introduce a trait for these reusable methods, but adding a trait for just one or two methods might not be justified at this stage.
Please note that AdminController already contains its own implementation of a similar method (https://github.com/joomla/joomla-cms/blob/6.1-dev/libraries/src/MVC/Controller/AdminController.php#L479), which mirrors the one in FormController (https://github.com/joomla/joomla-cms/blob/6.1-dev/libraries/src/MVC/Controller/FormController.php#L506). That means that the two controller classes were designed to be independent. So maybe the two methods can stay here in FormController, then we can implement getRedirectToListUrl method to AdminController, too.
if it should not be in the base class then a trait is perfectly fine for this.
The trait would then only contains getRedirectToListUrl because AdminController does not need getRedirectToItemUrl. I'm unsure if that makes much sense.
you might be right, then please add the getRedirectToListUrl to the also to the admincontroller
you might be right, then please add the getRedirectToListUrl to the also to the admincontroller
Done, thanks ! FYI, I see many possible improvements to FormController code (especially for save method) to make easier to override when it is needed. As of right now, many child controllers in have to copy/paste the whole code of the method (for example https://github.com/joomla/joomla-cms/blob/6.1-dev/administrator/components/com_finder/src/Controller/FilterController.php#L40) to add it own logic which is not nice. We should improve it.
that's true, if you find a nice way to split the save function into multiple so easier overriding is possible please go for it.
I cannot speak about whether it is needed.
But I would suggest to use different naming, like getRedirectUrl...(), getRedirectUrlFoo(), getRedirectUrlBar().
It should be more easy to search and read in my opinion.
I cannot speak about whether it is needed.
The two methods provide quicker way to get the URLs instead of having to repeat writing longer code to build these URLs everywhere (the two classes modified in this PR are just a start, there are many code like that in child classes)
But I would suggest to use different naming, like getRedirectUrl...(), getRedirectUrlFoo(), getRedirectUrlBar()
I'm open for suggestion. In my extensions, I use getViewListUrl and getViewItemUrl. I think the suggested getRedirectUrl does not really describe what the methods do.
I think the suggested getRedirectUrl does not really describe what the methods do.
I just mean "flip words" around getRedirectToItemUrl => getRedirectUrlToItem π
| Labels |
Added:
Feature
|
||
I just mean "flip words" around
getRedirectToItemUrl=>getRedirectUrlToItem
Thanks, it's indeed better, but having a little naming conflict with the existing method getRedirectToItemAppend. But I changed the name as suggested.
that's true, if you find a nice way to split the save function into multiple so easier overriding is possible please go for it.
@HLeithner PR created #46537. I also include changes from this PR in that PR to make the code shorter/more clear.
| Labels |
Added:
PBF
|
||
I have tested this item β successfully on 6be034e
I have tested this item β
successfully on 6be034e
Tested with com_content, com_users and com_contact. No problems found.
I have tested this item β
successfully on 6be034e
Hi @joomdonation, I have tested this successfully during PBF 2026 on 2 different installations - PBF Rochen PHP 8.3 instance and my own hosting PHP 8.5 instance.
For the PBF Rochen instance, I tried multi-lingual articles, with different ACL Levels, greek/French characters, Language Associations, as well as past and future Publishing dates, deletion, restoration, played w/ display options, with/without images, with tags, notes...
For my own hosting instance, 5000 word document in 3 languages with associations, table, code snippet, different author user, deleting, restoring, playing with display options, etc...
Really tried to beat it up ;)
I have tested this item β
successfully on 6be034e
I have completed the functional verification of the patch and can confirm that it is working correctly. SHA: 6be034e
I performed the following tests in the browser:
Cancel: Verified that it correctly redirects to the Articles list.
Save & Close: Verified that it correctly redirects to the Articles list after saving.
Save (Apply): Verified that it correctly redirects back to the Article edit page (item view) after saving.
All redirection flows triggered the new getRedirectUrlToItem() and getRedirectUrlToList() methods as expected, maintaining the standard Joomla behavior while using the refactored, centralized logic.
| Status | Pending | ⇒ | Ready to Commit |
RTC
@joomdonation can you please resolve the conflicts then I can merge this here too. thanks
| Status | Ready to Commit | ⇒ | Closed |
| Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2026-02-11 13:49:04 |
| Closed_By | ⇒ | joomdonation | |
| Labels |
Added:
RTC
|
||
@HLeithner The changes in this PR is already included in #46537, so I'm closing this one.
thanks, that was not fully clear to be.
We have the same "issue" in the
AdminController, not sure ifFromControlleris the right place to implement this.