Skip to content
Snippets Groups Projects
Commit 13b25988 authored by David Siegfried's avatar David Siegfried Committed by Rasmus Fuhse
Browse files

add data-secure to form, closes #2907

Closes #2907

Merge request studip/studip!1961
parent 413c5b99
No related branches found
No related tags found
No related merge requests found
...@@ -22,6 +22,7 @@ class Form extends Part ...@@ -22,6 +22,7 @@ class Form extends Part
protected $success_message = ''; protected $success_message = '';
protected $collapsable = false; protected $collapsable = false;
protected $data_secure = true;
//to identify a form element //to identify a form element
protected $id = null; protected $id = null;
...@@ -276,6 +277,21 @@ class Form extends Part ...@@ -276,6 +277,21 @@ class Form extends Part
return $this; 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. * Sets the ID if this form. This ID is only relevant for plugins to identify this Form object.
* @param string|null $id * @param string|null $id
......
...@@ -22,6 +22,7 @@ $form_id = md5(uniqid()); ...@@ -22,6 +22,7 @@ $form_id = md5(uniqid());
<? endif ?> <? endif ?>
@submit="submit" @submit="submit"
novalidate novalidate
<?= $form->getDataSecure() ? 'data-secure' : '' ?>
id="<?= htmlReady($form_id) ?>" id="<?= htmlReady($form_id) ?>"
data-inputs="<?= htmlReady(json_encode($inputs)) ?>" data-inputs="<?= htmlReady(json_encode($inputs)) ?>"
data-debugmode="<?= htmlReady(json_encode($form->getDebugMode())) ?>" data-debugmode="<?= htmlReady(json_encode($form->getDebugMode())) ?>"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment