CMS property changes when used in custom code

Hi there, I’m having some trouble understanding what I’m doing differently on two pages.

I’m trying to set up a contest voting system that consists of two pages.

  • Page 1 is the landing page that uses a collection list element where I display only two random contest entries.
    Once the user clicks on the vote button below an entry, they are redirected to the CMS collection page that has the winning entry on the left side and a new random entry on the right side.
    This first page works as expected - you choose the winner and you’re redirected to the correct CMS collection item page.

  • Page 2 is where I’m lost. I’m pretty sure I’m using the same custom code to perform the redirect, but instead of using the slug property from the CMS (like on page 1), it adds two other properties and so the redirect fails.

Any ideas on what I’m doing wrong or any ideas on an alternate approach?

I also tried to make my own form submit button with an embed component but that had the same issue of redirecting to the weird URL.

Basically, how can I get the form submit to redirect to the correct dynamic url like on page 1?


Page 1 preview: LINK
Page 1 live: LINK

Page 2 preview: LINK
Page 2 live (random item): LINK