diff --git a/lib/classes/forms/Form.php b/lib/classes/forms/Form.php index 892e144533f6e7f251f15feb45a0eeda6a5ba5e0..0afe442b5364f210c8e9cec1af72104e3144f86d 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; @@ -276,6 +277,21 @@ class Form extends Part return $this; } + /** + * 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 diff --git a/templates/forms/form.php b/templates/forms/form.php index 094805e9e597dcf9c646486fd970a825977d7f1f..05b0b302fe8e38231c7fc12cc90dd3ca8266ae1c 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())) ?>"