LSattr_html_select_list : simplify addToForm() method using parent method

This commit is contained in:
Benjamin Renard 2014-06-18 00:13:06 +02:00
parent 316aee7f49
commit 110f162367

View file

@ -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,19 +56,12 @@ 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);
}
$element=parent::addToForm($form,$idForm,$data);
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))) );
// On retourne un pointeur vers l'element ajouter
}
return $element;
}