LSattr_html_select_list : Use inarray LSformRule instead of regex

This commit is contained in:
Benjamin Renard 2014-06-10 16:51:12 +02:00
parent 4a646f2748
commit 73c9b385f8

View file

@ -64,15 +64,8 @@ class LSattr_html_select_list extends LSattr_html{
} }
// Mise en place de la regle de verification des donnees // Mise en place de la regle de verification des donnees
$regex_check_data='/'; $form -> addRule($this -> name, 'inarray', array('msg'=> 'Valeur incorrect','params' => array('possible_values' => array_keys($possible_values))) );
foreach ($possible_values as $val => $text) {
if($regex_check_data=='/')
$regex_check_data.='^'.preg_quote($val,'/').'$';
else
$regex_check_data.='|^'.preg_quote($val,'/').'$';
}
$regex_check_data.='/';
$form -> addRule($this -> name, 'regex', array('msg'=> 'Valeur incorrect','params' => array('regex' => $regex_check_data)) );
// On retourne un pointeur vers l'element ajouter // On retourne un pointeur vers l'element ajouter
return $element; return $element;
} }