Jump to:

3375 Posts in 999 Topics by 712 members

Data Model Questions

SilverStripe Forums » Data Model Questions » [SOLVED] Redirect Form Action to page with target set to blank

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

Page: 1
Go to End
Author Topic: 311 Views
  • Optic Blaze
    Avatar
    Community Member
    155 Posts

    [SOLVED] Redirect Form Action to page with target set to blank Link to this post

    Hi there,

    I have a form that collects user data and once the person hits the submit button the form action redirects the user to a certain page.
    Like this:

    // FORM ACTION
    public static function PrintJobCard($data, $form) {
          $date = $data['JobDate'];
          $plumber = (int)$data['PlumberID'];
          return Controller::curr()->redirect("jobcardprint/".$plumber."/".$date);

    }

    I need the action to open up a new window...usually set in normal html forms with the target="_blank" parameter...how do i do this on the SS form action?

    Thanks

  • Optic Blaze
    Avatar
    Community Member
    155 Posts

    Re: [SOLVED] Redirect Form Action to page with target set to blank Link to this post

    Figured it out.... you need to set the target on the form you create and not on the redirect controller.

       //SEARCH FORM
       public function JobCardSearch() {
          return Form::create(
    $this,
    "JobCardSearch",
    FieldList::create(
             DateField::create("JobDate", "Job date")
             ),
          FieldList::create(
                FormAction::create("PrintJobCard","Print Card")
                   
             ),
             RequiredFields::create(array("JobDate","PlumberID"))
        )
        ->setTarget("_blank");

    311 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.