- LSformElement :: getPostData()

-> Suppression automatique des valeurs vides
- LSformElement_boolean :
	-> Modification des valeurs clefs : (0/1) => (no/yes)
This commit is contained in:
Benjamin Renard 2008-10-15 10:32:51 +00:00
parent 6fc4a82c77
commit 220dcd7352
3 changed files with 8 additions and 5 deletions

View file

@ -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 {

View file

@ -222,12 +222,15 @@ 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;
}
else {

View file

@ -49,7 +49,7 @@ class LSformElement_boolean extends LSformElement {
}
else {
foreach ($this -> values as $value) {
$return['html'] .= "<li class='LSformElement_boolean'><input type='radio' value='1' name='".$this -> name."[0]' ".(($this -> isTrue($this -> values))?'checked':'')." /> "._('Oui')."<input type='radio' value='0' name='".$this -> name."[0]' ".(($this -> isTrue($this -> values))?'':'checked')." /> "._('Non')."</li>\n";
$return['html'] .= "<li class='LSformElement_boolean'><input type='radio' value='yes' name='".$this -> name."[0]' ".(($this -> isTrue($this -> values))?'checked':'')." /> "._('Oui')."<input type='radio' value='no' name='".$this -> name."[0]' ".(($this -> isTrue($this -> values))?'':'checked')." /> "._('Non')."</li>\n";
}
}
$return['html'] .= "</ul>\n";
@ -74,7 +74,7 @@ class LSformElement_boolean extends LSformElement {
* @retval string Code HTML d'un champ vide.
*/
function getEmptyField() {
return "<input type='radio' value='1' name='".$this -> name."[0]' /> "._('Oui')."<input type='radio' value='0' name='".$this -> name."[0]' /> "._('Non');
return "<input type='radio' value='yes' name='".$this -> name."[0]' /> "._('Oui')."<input type='radio' value='no' name='".$this -> name."[0]' /> "._('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;