Skip to content

[4.5.1]: URL function params argument not respecting {id} #13603

Closed
@KatieMFritz

Description

@KatieMFritz

What happened?

Description

I'm using the following code to reload a page with the ID of a newly created "lead" entry from an entry form:

redirectInput(url(baseUrl, 'lead_id={id}')

It was working originally, but after upgrading to Craft 4.5, the params argument is no longer replacing {id} with the entry ID when the form gets submitted. Instead of ?lead_id={id}, the generated URL includes ?lead_id=%7Bid%7D.

It works if I only use the path argument: redirectInput(url("#{baseUrl}?lead_id={id}")) or if I use regular Twig template interpolation: redirectInput(url(baseUrl, "lead_id=#{formId}")).

However, those options don't work for me, because my baseUrl variable has an anchor in it. If I use the params argument, the anchor gets bumped to the end and everything works, but if I only use the path argument, the params get ignored because they come after the anchor. I can split up my anchor to a separate variable and concatenate everything, but I think this is a bug.

Side note: I don't know what that type of system-generated variable is actually called: {id}. Is it a token?

Steps to reproduce

  1. Create an entry form.
  2. For the redirect URL, use the URL function. Include {id} somewhere in the params argument.
  3. Load the page and inspect the generated redirect URL.

Expected behavior

We should see {id} in the URL params for the redirect URL. Submitting the form should replace {id} with the actual ID of the newly created entry in the new URL.

Actual behavior

The redirect URL params include ?%7Bid%7D, even after submitting the form.

Craft CMS version

Craft Pro 4.5.1

PHP version

8.2.7

Operating system and version

Darwin 22.5.0

Database type and version

MySQL 8.0.33

Image driver and version

No response

Installed plugins and versions

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions