aboutsummaryrefslogtreecommitdiff
path: root/lib/classes/forms/Input.php
diff options
context:
space:
mode:
authorMichaela Brückner <brueckner@data-quest.de>2024-01-02 08:55:04 +0000
committerMichaela Brückner <brueckner@data-quest.de>2024-01-02 08:55:04 +0000
commit502e6a104f200acc2f8ff81ba09257a6035406e5 (patch)
tree6c10c6662c822475c92814ec32d60951eda9cad8 /lib/classes/forms/Input.php
parentb6bdba58a8e090cb144bae382457c2e439d8a72a (diff)
new registry formular, re #1559
Closes #3533 Merge request studip/studip!1141
Diffstat (limited to 'lib/classes/forms/Input.php')
-rw-r--r--lib/classes/forms/Input.php30
1 files changed, 29 insertions, 1 deletions
diff --git a/lib/classes/forms/Input.php b/lib/classes/forms/Input.php
index aa3069b..9d2ad32 100644
--- a/lib/classes/forms/Input.php
+++ b/lib/classes/forms/Input.php
@@ -11,6 +11,7 @@ abstract class Input
protected $parent = null;
public $mapper = null;
public $store = null;
+ public $validate = null;
public $if = null;
public $permission = true;
public $required = false;
@@ -133,6 +134,21 @@ abstract class Input
return $this->name;
}
+ public function getTitle()
+ {
+ return $this->title;
+ }
+
+ public function hasValidation()
+ {
+ return $this->validate !== null;
+ }
+
+ public function getValidationCallback()
+ {
+ return $this->validate;
+ }
+
/**
* Returns the value of this input.
* @return null
@@ -216,6 +232,18 @@ abstract class Input
}
/**
+ * Sets the server-side verify function of this input. The callable returns true if the given value is okay, or
+ * false or a textstring representing the error.
+ * @param callable $verify
+ * @return $this
+ */
+ public function setValidationFunction(Callable $validate)
+ {
+ $this->validate = $validate;
+ return $this;
+ }
+
+ /**
* Sets a condition to display this input. The condition is a javascript condition which is used by vue to
* hide the input if the condition is not satisfies.
* @param string $if
@@ -261,7 +289,7 @@ abstract class Input
protected function extractOptionsFromAttributes(array &$attributes)
{
- $options = null;
+ $options = [];
if (isset($attributes['options'])) {
$options = $attributes['options'];
unset($attributes['options']);