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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

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