Hi,
I have a view that shows a list of bookings. By default that list shows the bookings to come in a future date. I want to offer the possibility to filter that list so a user can see all the bookings (including the ones in the past) and can filter on those who are still open to registration. I am using a get route to pass the search query. Things are working well, my controller gets the search query and I get the results that are filtered properly.
I am now at the stage where I want to add the filters on the view. I am using links to add a parameter / or to remove one. I thought I'd use the $uri->addQuery to create the links. And I created a little helper that should return the modified url to each links. But It looks like the returns 'are cumulative' and I am not making sense of what's happening.
Here's my helper:
PHP Code:
function addParamQuery($param,$value) {
$uri = current_url(true);
$uri->addQuery($param, $value);
return $uri;
}
And in my view, my filter links using the helper:
PHP Code:
<a href="<?= addParamQuery('registration', 'open') ?>">show open bookings</a>
<a href="<?= addParamQuery('date', 'all') ?>">show also past dates</a>
But here's the html I am getting when I am viewing /agenda :
Code:
<a href="http://localhost:8080/en/agenda?registration=open">show open bookings</a>
<a href="http://localhost:8080/en/agenda?registration=open&date=all">show also past dates</a>
I was expecting to get for the second link only agenda?date=all . Why is registration=open part of the url returned?
It looks like each call 'builds' on the previous rather than starting from the current url (without any parameter). I am not understanding why... and what I need to do to fix it.
Can anyone help?