noalyss-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Noalyss-commit] [noalyss] 02/04: Add function to ISelect to transform s


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 02/04: Add function to ISelect to transform set the value with the given array
Date: Thu, 21 Jan 2016 09:14:22 +0000

sparkyx pushed a commit to branch master
in repository noalyss.

commit 4fe344679b7a54db39aa6cfc1066f22097846068
Author: Dany De Bontridder <address@hidden>
Date:   Thu Jan 14 12:58:57 2016 +0100

    Add function to ISelect to transform set the value with the given array
---
 include/lib/class_iselect.php |   24 ++++++++++++++++++++++--
 1 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/include/lib/class_iselect.php b/include/lib/class_iselect.php
index 2119bf1..27848cd 100644
--- a/include/lib/class_iselect.php
+++ b/include/lib/class_iselect.php
@@ -71,8 +71,28 @@ class ISelect extends HtmlInput
                if ( $this->table == 1 )                  $a='<td>'.$r.'</td>';
         return $r;
     }
-
-
+   /**
+    * @brief set the value of an ISelect with the array , this array
+    * is bidimensional , the first dimension is the code to store and the 
second
+    * is the label to display.
+    * Example
+    * @code
+    * array(array('M'=>'Mister'),array('Ms'=>'Miss'));
+    * // will be turned into 
+    * array( array("value"=>'M,"label"=>"Mister")...)
+    * @endcode
+    * @param type $p_array
+    * @return type
+    */
+   public function transform($p_array) {
+        if (count($p_array)==0) return array();
+        $a_ret=array();
+        foreach ($p_array as $key=>$value) {
+            $a_ret['value']=$key;
+            $a_ret['label']=$value;
+            $this->value[]=$a_ret;
+        }
+    }
     static public function test_me()
     {
     }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]