mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-12-18 22:43:47 +01:00
LSform / LSformRule: only show default error message if rule does not trigger itself an error
This commit is contained in:
parent
2a0981a21e
commit
3298320b3d
2 changed files with 13 additions and 19 deletions
|
@ -252,20 +252,14 @@ class LSattribute extends LSlog_staticLoggerClass {
|
||||||
else {
|
else {
|
||||||
$check_data = $this -> getConfig('check_data', array());
|
$check_data = $this -> getConfig('check_data', array());
|
||||||
if(is_array($check_data)) {
|
if(is_array($check_data)) {
|
||||||
foreach ($check_data as $rule => $rule_infos) {
|
foreach ($check_data as $rule => $rule_options) {
|
||||||
if((!$form -> isRuleRegistered($rule))&&($rule!='')) {
|
// Check rule
|
||||||
LSerror :: addErrorCode('LSattribute_03',array('attr' => $this->name,'rule' => $rule));
|
if(!is_empty($rule) && !$form -> isRuleRegistered($rule)) {
|
||||||
|
LSerror :: addErrorCode('LSattribute_03', array('attr' => $this->name, 'rule' => $rule));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!isset($rule_infos['msg'])) {
|
// Add rule to form
|
||||||
$rule_infos['msg']=getFData(_('The value of field %{label} is invalid.'),$this -> getLabel());
|
$form -> addRule($this -> name, $rule, (is_array($rule_options)?$rule_options:array()));
|
||||||
}
|
|
||||||
else {
|
|
||||||
$rule_infos['msg']=__($rule_infos['msg']);
|
|
||||||
}
|
|
||||||
if(!isset($rule_infos['params']))
|
|
||||||
$rule_infos['params']=NULL;
|
|
||||||
$form -> addRule($this -> name,$rule,array('msg' => $rule_infos['msg'], 'params' => $rule_infos['params']));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -584,22 +584,22 @@ class LSform extends LSlog_staticLoggerClass {
|
||||||
*
|
*
|
||||||
* @retval boolean
|
* @retval boolean
|
||||||
*/
|
*/
|
||||||
public function addRule($element, $rule, $options=array()) {
|
public function addRule($element, $rule, $options=null) {
|
||||||
if ( isset($this ->elements[$element]) ) {
|
if ( isset($this ->elements[$element]) ) {
|
||||||
if ($this -> isRuleRegistered($rule)) {
|
if ($this -> isRuleRegistered($rule)) {
|
||||||
$this -> _rules[$element][]=array(
|
$this -> _rules[$element][] = array(
|
||||||
'name' => $rule,
|
'name' => $rule,
|
||||||
'options' => $options
|
'options' => (is_array($options)?$options:array()),
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LSerror :: addErrorCode('LSattribute_03',array('attr' => $element,'rule'=>$rule));
|
LSerror :: addErrorCode('LSattribute_03', array('attr' => $element, 'rule' => $rule));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LSerror :: addErrorCode('LSform_04',array('element' => $element));
|
LSerror :: addErrorCode('LSform_04', array('element' => $element));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue