From 220dcd73524bc529f60f5b161d80a93429a7e98d Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Wed, 15 Oct 2008 10:32:51 +0000 Subject: [PATCH] - LSformElement :: getPostData() -> Suppression automatique des valeurs vides - LSformElement_boolean : -> Modification des valeurs clefs : (0/1) => (no/yes) --- trunk/includes/class/class.LSattr_ldap_boolean.php | 4 ++-- trunk/includes/class/class.LSformElement.php | 3 +++ trunk/includes/class/class.LSformElement_boolean.php | 6 +++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/trunk/includes/class/class.LSattr_ldap_boolean.php b/trunk/includes/class/class.LSattr_ldap_boolean.php index 8eca3b35..0fa8b913 100644 --- a/trunk/includes/class/class.LSattr_ldap_boolean.php +++ b/trunk/includes/class/class.LSattr_ldap_boolean.php @@ -36,7 +36,7 @@ class LSattr_ldap_boolean extends LSattr_ldap { function getDisplayValue($data) { if ($data==NULL) return; - return ($this -> isTrue($data))?1:0; + return ($this -> isTrue($data))?'yes':'no'; } /** @@ -47,7 +47,7 @@ class LSattr_ldap_boolean extends LSattr_ldap { * @retval mixed La valeur traitée de l'attribut */ function getUpdateData($data) { - if ($data[0]==1) { + if ($data[0]=='yes') { return array($this -> config['true_value']); } else { diff --git a/trunk/includes/class/class.LSformElement.php b/trunk/includes/class/class.LSformElement.php index 29fe9eaf..238a79bc 100644 --- a/trunk/includes/class/class.LSformElement.php +++ b/trunk/includes/class/class.LSformElement.php @@ -222,11 +222,14 @@ class LSformElement { return true; } if (isset($_POST[$this -> name])) { + $return[$this -> name]=array(); if(!is_array($_POST[$this -> name])) { $_POST[$this -> name] = array($_POST[$this -> name]); } foreach($_POST[$this -> name] as $key => $val) { + if (!empty($val)) { $return[$this -> name][$key] = $val; + } } return true; } diff --git a/trunk/includes/class/class.LSformElement_boolean.php b/trunk/includes/class/class.LSformElement_boolean.php index af80c6a6..3a965aa3 100644 --- a/trunk/includes/class/class.LSformElement_boolean.php +++ b/trunk/includes/class/class.LSformElement_boolean.php @@ -49,7 +49,7 @@ class LSformElement_boolean extends LSformElement { } else { foreach ($this -> values as $value) { - $return['html'] .= "
  • isTrue($this -> values))?'checked':'')." /> "._('Oui')." isTrue($this -> values))?'':'checked')." /> "._('Non')."
  • \n"; + $return['html'] .= "
  • isTrue($this -> values))?'checked':'')." /> "._('Oui')." isTrue($this -> values))?'':'checked')." /> "._('Non')."
  • \n"; } } $return['html'] .= "\n"; @@ -74,7 +74,7 @@ class LSformElement_boolean extends LSformElement { * @retval string Code HTML d'un champ vide. */ function getEmptyField() { - return " "._('Oui')." "._('Non'); + return " "._('Oui')." "._('Non'); } /** @@ -91,7 +91,7 @@ class LSformElement_boolean extends LSformElement { if(!is_array($data)) { $data=array($data); } - if($data[0]==1) { + if($data[0]=='yes') { return true; } return;