Add with_accents parameter to LSformRule_alphanumeric and set config.LSobjects.LSpeople to use it

This commit is contained in:
Pierre Arnaud 2014-08-14 10:33:45 +02:00
parent 3ed59a28bd
commit ebf26c4591
2 changed files with 15 additions and 6 deletions

View file

@ -235,6 +235,7 @@ $GLOBALS['LSobjects']['LSpeople'] = array (
'default_value' => 'toto', 'default_value' => 'toto',
'check_data' => array ( 'check_data' => array (
'alphanumeric' => array( 'alphanumeric' => array(
'params' => array('with_accents' => true),
'msg' => 'The first name must contain alphanumeric values only.' 'msg' => 'The first name must contain alphanumeric values only.'
), ),
), ),

View file

@ -37,9 +37,17 @@ class LSformRule_alphanumeric extends LSformRule {
* @return boolean true si la valeur est valide, false sinon * @return boolean true si la valeur est valide, false sinon
*/ */
function validate ($value,$options=array(),$formElement) { function validate ($value,$options=array(),$formElement) {
if (isset($options['params']['with_accents']) && $options['params']['with_accents'] == true){
$regex = '/^[a-zA-Z0-9àâäéèêëîïôöù]+$/';
}
else {
$regex = '/^[a-zA-Z0-9]+$/'; $regex = '/^[a-zA-Z0-9]+$/';
}
LSsession :: loadLSclass('LSformRule_regex'); LSsession :: loadLSclass('LSformRule_regex');
return LSformRule_regex :: validate($value,$regex,$formElement); return LSformRule_regex :: validate($value,$regex,$formElement);
} }
} }