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.

Form Questions /

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

Director::redirect -> New Window


Go to End
Reply


3 Posts   3462 Views

Avatar
hu

Community Member, 21 Posts

5 March 2009 at 5:29am

Edited: 05/03/2009 2:58pm

class MapPage_Controller extends Page_Controller {
...

function doForm($data, $form) {
...
$url = 'http://maps.google.com/maps?f=d&hl=de&saddr=' . $source . '&daddr=' . $destination;
Director::redirect($url);
}
}

I want to redirect into a new window (like target="_blank"). Is there a way to do this?

Avatar
UncleCheese

Forum Moderator, 4096 Posts

5 March 2009 at 6:05am

Edited: 05/03/2009 6:06am

Not without javascript, and that introduces an accessibility issue. To achieve what you're looking for, you need to have PHP draw a script tag and open a new window with the desired location.

Avatar
hu

Community Member, 21 Posts

31 March 2009 at 4:33am

Edited: 31/03/2009 4:37am

Now i find a way to do this...

class MapPage_Controller extends Page_Controller {
...
function Form() {
$fields = new FieldSet(
...
);
$actions = new FieldSet(
new FormAction('doForm', 'Show')
);
$form = new Form($this, 'Form', $fields, $actions);
$form->setTarget('_blank');
return $form;
}
function doForm($data, $form) {
...
$url = 'http://maps.google.com/maps?f=d&hl=de&saddr=' . $source . '&daddr=' . $destination;
Director::redirect($url);
}
}