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.

Data Model Questions /

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


Reply


2 Posts   725 Views

Avatar
Optic Blaze

Community Member, 165 Posts

1 February 2014 at 10:42pm

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

Avatar
Optic Blaze

Community Member, 165 Posts

1 February 2014 at 11:00pm

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