Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w



3 Posts   3311 Views


6 January 2012 at 12:13am Community Member, 74 Posts

Hi Guys,

I have a form that submits and updates a data object but prior to the actual update I want to check whether a link actually exists on a page. If the link exists then the update can progress otherwise if the link doesn't exist then it should redirect the user back to the original form and give them a notice.

But what is happening is that I am getting a warning

[User Warning] Already directed to /placements/complete/3; now trying to direct to /placements

So the code is failing the initial "if($this->checkforlink() == false){" check and doing the redirect, but then continuing on the execution of the rest of the updatecompletion() which is not what I want. I want to check for the link, if it fails, end execution and then redirect to the new page.

If I try to exit() after Director::redirect('/placements/complete/'.$data['AdvertisementID']); then all I get is a white screen.

I might be missing something extremely obvious here, but would love any help you might have.

public function checkforlink() {

// test to simulate a failed check for the link
return false;


public function updatecompletion($data, $form) {

if($this->checkforlink() == false){

Session::set('notice', true);
Session::set('noticeType', 'bad');
Session::set('noticeText', 'Opps - It doesn\'t look like that link is actually showing up in the location you have provided yet. Please check that it exists before setting the placement as completed.');



// UPDATE Code goes in here

Session::set('notice', true);
Session::set('noticeType', 'good');
Session::set('noticeText', 'Okay, thanks for letting us know that this placement is completed.');



Session::set('notice', true);
Session::set('noticeType', 'bad');
Session::set('noticeText', 'Opps - It doesn\'t look like that placement was for you. Nice try though ;)');




6 January 2012 at 2:41am Community Member, 189 Posts

on your Director::redirect() try return Director::redirect()


6 January 2012 at 3:36am Community Member, 74 Posts

SOLVED! Thanks

Also I guess it should be

return $this->redirect()

As Director::redirect() is deprecated