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

@ -234,9 +234,10 @@ $GLOBALS['LSobjects']['LSpeople'] = array (
'required' => 1, 'required' => 1,
'default_value' => 'toto', 'default_value' => 'toto',
'check_data' => array ( 'check_data' => array (
'alphanumeric' => array( 'alphanumeric' => array(
'msg' => 'The first name must contain alphanumeric values only.' 'params' => array('with_accents' => true),
), 'msg' => 'The first name must contain alphanumeric values only.'
),
), ),
'rights' => array( 'rights' => array(
'self' => 'r', 'self' => 'r',

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) {
$regex = '/^[a-zA-Z0-9]+$/';
LSsession :: loadLSclass('LSformRule_regex');
return LSformRule_regex :: validate($value,$regex,$formElement); if (isset($options['params']['with_accents']) && $options['params']['with_accents'] == true){
$regex = '/^[a-zA-Z0-9àâäéèêëîïôöù]+$/';
}
else {
$regex = '/^[a-zA-Z0-9]+$/';
}
LSsession :: loadLSclass('LSformRule_regex');
return LSformRule_regex :: validate($value,$regex,$formElement);
} }
} }