From 67fc662e4c198afb781ee592421c10af0c58e936 Mon Sep 17 00:00:00 2001 From: diegoguidotti Date: Mon, 8 Jul 2013 20:37:29 +0200 Subject: [PATCH] Use the default value instead of null value --- library/dbmng/dbmng.php | 34 +++++++++++------------- library/dbmng/dbmng_extend_functions.php | 2 +- tests/enpimodule/enpimodule.module | 2 +- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/library/dbmng/dbmng.php b/library/dbmng/dbmng.php index d1a822d..78582ec 100644 --- a/library/dbmng/dbmng.php +++ b/library/dbmng/dbmng.php @@ -64,20 +64,13 @@ function dbmng_get_form_array($id_table){ { if($fld->pk == 1) $aForm['primary_key'] = $fld->field_name; - //if(strpos($fld->field_name, "id_") !== false ) - // $aForm['primary_key'] = "id_test"; - - - $aFields[$fld->field_name] = array('label' => $fld->field_label, 'type' => $fld->id_field_type, 'value' => null, 'nullable' => $fld->nullable, + 'default' => $fld->default_value, 'field_function' => $fld->field_function); - if(($fld->default_value)!=null){ - $aFields[$fld->field_name]['default']=$fld->default_value; - } } @@ -85,7 +78,7 @@ function dbmng_get_form_array($id_table){ $aForm['primary_key']='id_'.$aForm['table_name']; } $aForm['fields']=$aFields; - print_r($aFields); + return $aForm; } @@ -206,8 +199,8 @@ function dbmng_create_form($aForm, $aParam) $html .= "'); - echo($sType.'|'.$sValue.'|'.($df==null).'|
'); - if(strlen($sValue)==0 && $df==null) + //if exists a default value use the default values instead of null + if(strlen($sValue)==0 && is_null($x_value['default']) ) { $sVal .= "NULL, "; } else{ if(strlen($sValue)==0){ - $sValue=$df; + $sValue=$x_value['default']; } switch ($sType) { diff --git a/library/dbmng/dbmng_extend_functions.php b/library/dbmng/dbmng_extend_functions.php index b27d40a..a5f8d1f 100644 --- a/library/dbmng/dbmng_extend_functions.php +++ b/library/dbmng/dbmng_extend_functions.php @@ -8,4 +8,4 @@ function dbmng_id_test() } -?> \ No newline at end of file +?> diff --git a/tests/enpimodule/enpimodule.module b/tests/enpimodule/enpimodule.module index 0fb7071..39ac870 100644 --- a/tests/enpimodule/enpimodule.module +++ b/tests/enpimodule/enpimodule.module @@ -76,7 +76,7 @@ function say_hello_world() { $id_table = $_REQUEST['tbl']; $aForm = dbmng_get_form_array($id_table); - //the param array stores sone variabble used by the renderer + //the param array stores some custom variable used by the renderer $aParam = array(); //hidden_vars are some hidden variables used by the form creation $aParam['hidden_vars']=array();