21278 Posts in 5728 Topics by 2599 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 950 Views |
-
Director::redirect()

6 January 2012 at 12:13am
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.');Director::redirect('/placements/complete/'.$data['AdvertisementID']);
}
// UPDATE Code goes in here
if($Advertisement->write()){Session::set('notice', true);
Session::set('noticeType', 'good');
Session::set('noticeText', 'Okay, thanks for letting us know that this placement is completed.');Director::redirect('/placements');
}else{
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 ;)');Director::redirect('/placements');
}
} -
Re: Director::redirect()

6 January 2012 at 2:41am
on your Director::redirect() try return Director::redirect()
-
Re: Director::redirect()

6 January 2012 at 3:36am
SOLVED! Thanks
Also I guess it should be
return $this->redirect()
As Director::redirect() is deprecated
Thanks
| 950 Views | ||
|
Page:
1
|
Go to Top |

