Will
Will

Reputation: 4705

Silverstripe redirects to default action with anchor links

After a form is submitted and handled, I want it to redirect back to the page with the form on it, with a #anchor link, like this:

/facility/some-facility#form

How is this best achieved with Silverstripe?

return $this->redirect($this->Link .'#form')

sends the browser back to

/facility/some-facility/Form#form

and redirectBack() does not take any arguments

Upvotes: 0

Views: 698

Answers (2)

Will
Will

Reputation: 4705

As pointed out by Colymba in the comments, the ->Link() is a method, not a property

return $this->redirect($this->Link() . '#facility-enquiry');

gives the correct redirect.

Upvotes: 2

Will
Will

Reputation: 4705

Obviously one option is

return $this->redirect($_SERVER["HTTP_REFERER"] . "#facility-enquiry");

But that seems a bit basic when all the other redirection functions offer a bit of error checking etc.

Upvotes: 1

Related Questions