Jump to:

2002 Posts in 1422 Topics by 616 members

Form Questions

SilverStripe Forums » Form Questions » Director::redirect -> New Window

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

Page: 1
Go to End
Author Topic: 3168 Views
  • hu
    Avatar
    Community Member
    21 Posts

    Director::redirect -> New Window Link to this post

    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?

  • UncleCheese
    Avatar
    4085 Posts

    Re: Director::redirect -> New Window Link to this post

    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.

  • hu
    Avatar
    Community Member
    21 Posts

    Re: Director::redirect -> New Window Link to this post

    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);
       }
    }

    3168 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.