diff --git a/lib/classes/forms/Form.php b/lib/classes/forms/Form.php index 36a2e7d0fb2c4be9ca468dc17ecf057d6fcae364..9c22c4f397f53e7e78b06df6637e0d2f4effff5c 100644 --- a/lib/classes/forms/Form.php +++ b/lib/classes/forms/Form.php @@ -297,6 +297,8 @@ class Form extends Part \PageLayout::postSuccess($this->success_message); } page_close(); + //This indicates that the form has been stored successfully. + echo "STUDIPFORM_STORE_SUCCESS"; die(); } } diff --git a/lib/classes/forms/Input.php b/lib/classes/forms/Input.php index 9d2ad327caef281ab4924d2cc8c5f8f64857b8e1..ef506e9fe2f95b4e7fda8a079be9abfa2b108fd4 100644 --- a/lib/classes/forms/Input.php +++ b/lib/classes/forms/Input.php @@ -150,12 +150,17 @@ abstract class Input } /** - * Returns the value of this input. - * @return null + * Returns the value of this input. If $this->value is a callable this->getValue() returns the computed result. + * @return mixed */ public function getValue() { - return $this->value; + if (is_callable($this->value)) { + $callable = $this->value; + return $callable(); + } else { + return $this->value; + } } /** diff --git a/resources/assets/javascripts/bootstrap/forms.js b/resources/assets/javascripts/bootstrap/forms.js index c34a0c1bf948ef6d9ebf1ff37b2477b7f1d04dcd..764361291f77d28c0cadff7966bd1bb4eab316f3 100644 --- a/resources/assets/javascripts/bootstrap/forms.js +++ b/resources/assets/javascripts/bootstrap/forms.js @@ -1,4 +1,5 @@ import { $gettext, $gettextInterpolate } from '../lib/gettext'; +import Report from '../lib/report.js'; // Allow fieldsets to collapse $(document).on( @@ -291,9 +292,12 @@ STUDIP.ready(function () { url: v.STUDIPFORM_AUTOSAVEURL, data: params, type: 'post', - success() { - if (v.STUDIPFORM_REDIRECTURL) { - window.location.href = v.STUDIPFORM_REDIRECTURL + success(output) { + if (output === 'STUDIPFORM_STORE_SUCCESS' && v.STUDIPFORM_REDIRECTURL) { + //The form has been stored successfully: + window.location.href = v.STUDIPFORM_REDIRECTURL; + } else if (output !== 'STUDIPFORM_STORE_SUCCESS') { + Report.error($gettext('Es ist ein Fehler aufgetreten'), output); } } });