Commit c067999a authored by jelles's avatar jelles
Browse files

Issue #2036153 by doronsever: How to use equals to another field progrmatically.

parent fd2ffb7d
......@@ -933,13 +933,16 @@ function _clientside_validation_set_equal($name, $title, $value, &$js_rules, $me
if ($webform) {
$js_rules[$name]['equalTo'] = ':input[name=\'submitted[' . $value['form_key'] . ']\']';
}
else {
elseif (is_array($value)) {
$js_rules[$name]['equalTo'] = ':input[name=\'' . $value['element_name'] . '\']';
}
else {
$js_rules[$name]['equalTo'] = ':input[name=\'' . $value . '\']';
}
if (empty($message)) {
$variables = array(
'message' => '!title field has to be equal to !firstone.',
'placeholders' => array('!title' => $title, '!firstone' => $value['name']),
'message' => is_array($value) ? '!title field has to be equal to !firstone.' : 'Field values must match',
'placeholders' => is_array($value) ? array('!title' => $title, '!firstone' => $value['name']) : array(),
'error_type' => 'equalto',
'element_name' => $name,
);
......
......@@ -147,6 +147,9 @@ function _clientside_validation_set_fapi_validation($element, $rule, $params, &$
}
_clientside_validation_set_regex_pcre($name, $title, $js_rules, $expression, $message, 'decimal');
break;
case 'fapi_validation_rule_match_field';
_clientside_validation_set_equal($name, $title, $params[0], $js_rules);
break;
default:
$context = array('type' => 'fapi', 'rule' => $rule, 'message' => $message, 'params' => $params);
drupal_alter('clientside_validation_rule', $js_rules, $element, $context);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment