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

Director::redirect -> New Window


Reply

3 Posts   3209 Views

Avatar
hu

5 March 2009 at 5:29am (Last edited: 5 March 2009 2:58pm), Community Member, 21 Posts

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

5 March 2009 at 6:05am (Last edited: 5 March 2009 6:06am), 4085 Posts

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

31 March 2009 at 4:33am (Last edited: 31 March 2009 4:37am), Community Member, 21 Posts

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