Page Redirecting

In version v2026.11.0 (2026/06/03) I noticed an issue with redirection behavior.

The fix mentioned:

  • Edit Page return page fixed

works for Edit pages, but it seems other cases are still affected.

Issue:

In the List Page, the following redirect does NOT work:

// Page Redirecting event
public function pageRedirecting(?string &$url): void
{
    $url = "Platform"; // or $url = HtmlEncode(GetUrl("Platform"));
}

The page simply does not navigate to the specified URL.

Expected behavior:

The List page should redirect to "Platform" when pageRedirecting() is triggered.

Actual behavior:

No redirect happens on List pages, while Edit Page return navigation is fixed correctly in this version.

Question:

Is this fix intended only for Edit pages, or should it also cover List pages and other page types?

Platform does not sound like a normal page, is it a Custom File or an external page? If it is Custom File, make sure the URL is correct. You can check valid routes and URLs by php bin/console router:debug, see Console Commands.

If you have added the route recently or using "production" mode, make sure you have cleared cache, read: Clearing Symfony Cache.

While reviewing the code, I noticed something that may need clarification.

In page classes, terminate() can set:

$this->Response = new RedirectResponse(GetUrl($url), Config("REDIRECT_STATUS_CODE"));

However, in BaseController::runPage(), $page->Response is only checked before page rendering:

if (($response = $page->Response) instanceof Response) {
    ...
    $page->terminate();
}

Later, terminate() is called again, but I cannot find any code that re-reads $page->Response after terminate() has executed.

From my reading, if terminate() creates a new RedirectResponse, that response does not appear to be assigned back to the controller's $response variable and therefore may never be returned.

Am I missing another location where $page->Response is consumed after terminate() runs, or is the Response created inside terminate() no longer used in the Symfony-based architecture?

I noticed another potential issue related to IsModal.

In terminate() there is logic like:

if ($this->IsModal) {
    ...
}

However, IsModal is typically assigned during run():

public function run(): void
{
    // Is modal
    $this->IsModal = IsModal();
}

I have encountered cases where terminate() is executed before run() (or before other methods that initialize $this->IsModal). In those situations, $this->IsModal may not contain the expected value, which can lead to incorrect behavior.

As a workaround, I have sometimes used:

public function pageUnload(): void
{
    $this->IsModal = IsModal();
}

to ensure the property is initialized before terminate() uses it.

Would it be safer for terminate() to call IsModal() directly instead of relying on $this->IsModal, for example:

if (IsModal()) {
    ...
}

or is there another part of the framework lifecycle that guarantees $this->IsModal has already been initialized before terminate() is called?

  1. Note that terminate() can only be called once, if you call it again, since it is already terminated, it returns early.
  2. Normal usage calls run() then terminate(), the latter will not be called before run(). If there are special cases that you terminate early yourself in some server event, you should know if the page is used as modal or not, and you can set the response as JSON response or Redirect response accordingly. (There should be no need to use pageUnload() just to set IsModal.)

Still, my first issue has not been properly answered.

1.

The following code does NOT work:

public function pageRedirecting(?string &$url): void
{
    $url = "Platform"; // or $url = HtmlEncode(GetUrl("Platform"));
}

It does not matter whether "Platform" is a table name or a custom page. The redirect simply does not behave as expected.

This issue is already partially discussed here:

https://discourse.hkvstore.com/t/page-redirecting/11552/3?u=kayra

But there is still no clear explanation or working solution provided.


2.

Assume an Add page is opened inside a modal (it does not matter whether the parent is a custom page or a list page of another table).

At the end of the form submission, the modal must be closed properly.

For this scenario, the following is required:

public function pageUnload(): void
{
    $this->IsModal = IsModal();
}

Without this, the modal does not close correctly and instead the user is redirected to the parent page unexpectedly.

This behavior is inconsistent and needs a proper explanation or fix.

  1. Note that if "Platform" is not a valid route, you will get "No route found" error (and no redirection). That's why I suggested that you should:

    You can check valid routes and URLs by php bin/console router:debug , see Console Commands.

    Make sure the displayed valid routes and their URLs contains where you want to direct (e.g. "Platform".

  2. A modal dialog is closed by returning JSON properly. In normal operation by generated code, the server side will return properly JSON response (no error, or has error in JSON, or has URL in JSON) and then the dialog will be closed. If you return JSON response yourself by server event, you may want to press F12 in your browser, check for JavaScript error in Console pnale and check HTTP response in Network panel, and see what your response actually returns, try to find why it does not close the dialog. If you returns text/html or invalid JSON, it won't work.