diff options
| author | David Siegfried <david.siegfried@uni-vechta.de> | 2023-07-21 07:46:33 +0000 |
|---|---|---|
| committer | Rasmus Fuhse <fuhse@data-quest.de> | 2023-07-21 07:46:33 +0000 |
| commit | 13b2598871914bafdb585fe98d3ae345d2631a8a (patch) | |
| tree | 78517d8e4923aa4cb31267d55124383b961c2b4a | |
| parent | 413c5b998bf8884bb658e7311e772945fd1edb2d (diff) | |
add data-secure to form, closes #2907
Closes #2907
Merge request studip/studip!1961
| -rw-r--r-- | lib/classes/forms/Form.php | 16 | ||||
| -rw-r--r-- | templates/forms/form.php | 1 |
2 files changed, 17 insertions, 0 deletions
diff --git a/lib/classes/forms/Form.php b/lib/classes/forms/Form.php index 892e144..0afe442 100644 --- a/lib/classes/forms/Form.php +++ b/lib/classes/forms/Form.php @@ -22,6 +22,7 @@ class Form extends Part protected $success_message = ''; protected $collapsable = false; + protected $data_secure = true; //to identify a form element protected $id = null; @@ -277,6 +278,21 @@ class Form extends Part } /** + * Sets if the form should be secured against accidental leaving of the page. Standard is on. + * @param $data_secure + * @return $this + */ + public function setDataSecure($data_secure) + { + $this->data_secure = $data_secure; + return $this; + } + + public function getDataSecure() { + return $this->data_secure; + } + + /** * Sets the ID if this form. This ID is only relevant for plugins to identify this Form object. * @param string|null $id * @return Form $this diff --git a/templates/forms/form.php b/templates/forms/form.php index 094805e..05b0b30 100644 --- a/templates/forms/form.php +++ b/templates/forms/form.php @@ -22,6 +22,7 @@ $form_id = md5(uniqid()); <? endif ?> @submit="submit" novalidate + <?= $form->getDataSecure() ? 'data-secure' : '' ?> id="<?= htmlReady($form_id) ?>" data-inputs="<?= htmlReady(json_encode($inputs)) ?>" data-debugmode="<?= htmlReady(json_encode($form->getDebugMode())) ?>" |
