[icinga-checkins] icinga.org: icingaweb2-module-director/master: DataTypeNumber: filter and validate numbers

git at icinga.org git at icinga.org
Wed May 25 08:17:08 CEST 2016


Module: icingaweb2-module-director
Branch: master
Commit: 7fea8c47877e823cee119432850392d25d305a88
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=7fea8c47877e823cee119432850392d25d305a88

Author: Thomas Gelf <thomas at gelf.net>
Date:   Wed May 25 08:14:39 2016 +0200

DataTypeNumber: filter and validate numbers

---

 library/Director/DataType/DataTypeNumber.php |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/library/Director/DataType/DataTypeNumber.php b/library/Director/DataType/DataTypeNumber.php
index d0c26b6..cd47f88 100644
--- a/library/Director/DataType/DataTypeNumber.php
+++ b/library/Director/DataType/DataTypeNumber.php
@@ -4,12 +4,15 @@ namespace Icinga\Module\Director\DataType;
 
 use Icinga\Module\Director\Hook\DataTypeHook;
 use Icinga\Module\Director\Web\Form\QuickForm;
+use Icinga\Module\Director\Data\ValueFilter\FilterInt;
 
 class DataTypeNumber extends DataTypeHook
 {
     public function getFormElement($name, QuickForm $form)
     {
-        $element = $form->createElement('text', $name);
+        $element = $form->createElement('text', $name)
+            ->addValidator('int')
+            ->addFilter(new FilterInt);
 
         return $element;
     }



More information about the icinga-checkins mailing list