From 110f162367f8a6a05f2e1772d0465e7d84fcbf99 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Wed, 18 Jun 2014 00:13:06 +0200 Subject: [PATCH] LSattr_html_select_list : simplify addToForm() method using parent method --- .../class/class.LSattr_html_select_list.php | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/public_html/includes/class/class.LSattr_html_select_list.php b/public_html/includes/class/class.LSattr_html_select_list.php index 6025866e..7bfeaae5 100644 --- a/public_html/includes/class/class.LSattr_html_select_list.php +++ b/public_html/includes/class/class.LSattr_html_select_list.php @@ -42,6 +42,8 @@ */ class LSattr_html_select_list extends LSattr_html{ + var $LSformElement_type = 'select'; + /** * Ajoute l'attribut au formualaire passer en paramètre * @@ -54,22 +56,15 @@ class LSattr_html_select_list extends LSattr_html{ function addToForm (&$form,$idForm,$data=NULL) { $possible_values=$this -> getPossibleValues(); $this -> config['text_possible_values'] = $possible_values; - $element=$form -> addElement('select', $this -> name, $this -> config['label'],$this -> config, $this); - if(!$element) { - LSerror :: addErrorCode('LSform_06',$this -> name); - return; - } - if ($data) { - $element -> setValue($data); - } - - // Mise en place de la regle de verification des donnees - $form -> addRule($this -> name, 'inarray', array('msg'=> 'Valeur incorrect','params' => array('possible_values' => array_keys($possible_values))) ); + $element=parent::addToForm($form,$idForm,$data); - // On retourne un pointeur vers l'element ajouter + if ($element) { + // Mise en place de la regle de verification des donnees + $form -> addRule($this -> name, 'inarray', array('msg'=> 'Valeur incorrect','params' => array('possible_values' => array_keys($possible_values))) ); + } return $element; } - + /** * Retourne un tableau des valeurs possibles de la liste *