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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Form Questions /

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

Director::redirect -> New Window


Go to End


3 Posts   4515 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, 4102 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);
}
}