Add function to ISelect to transform set the value with the given array
This commit is contained in:
parent
a5b75843e0
commit
4fe344679b
1 changed files with 22 additions and 2 deletions
|
|
@ -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()
|
||||
{
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue