Skip to content

Commit 62d5d49

Browse files
author
Dave MacFarlane
committed
Redirect after successful save
1 parent 271c784 commit 62d5d49

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

php/libraries/NDB_Form.class.inc

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,15 @@ class NDB_Form extends NDB_Page
6666
* Attempts to validate the form (using the defined rules) and
6767
* saves the validated data into the database
6868
*
69-
* @return void
70-
* @access public
69+
* @return bool
7170
*/
72-
function save()
71+
public function save() : bool
7372
{
74-
if ($this->form->validate()) {
75-
$this->form->process([&$this, "_save"]);
76-
}
73+
if (!$this->form->validate()) {
74+
return false;
75+
}
76+
$this->form->process([&$this, "_save"]);
77+
return true;
7778
}
7879

7980
/**
@@ -129,7 +130,9 @@ class NDB_Form extends NDB_Page
129130
{
130131
$this->setup();
131132
if ($request->getMethod() === "POST") {
132-
$this->save();
133+
if ($this->save()) {
134+
return new \LORIS\Http\Response\JSON\SeeOther($request->getURI());
135+
}
133136
}
134137

135138
return (new \LORIS\Http\Response())

0 commit comments

Comments
 (0)