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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Data Model Questions /

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

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


Go to End


2 Posts   1730 Views

Avatar
Optic Blaze

Community Member, 190 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, 190 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");