Commit a9a664af authored by Jelle Sebreghts's avatar Jelle Sebreghts
Browse files

Issue #1533664 by ramsegal: Fixed custom messages when using fapi integration.

parent ed386396
......@@ -345,13 +345,13 @@ function _clientside_validation_set_number($name, $title, &$js_rules, $message =
/**
* Set validation rule for decimal fields.
*/
function _clientside_validation_set_number_decimal($name, $title, $decimalpoint, &$js_rules) {
function _clientside_validation_set_number_decimal($name, $title, $decimalpoint, &$js_rules, $message = '') {
$title = variable_get('clientside_validation_prefix', '') . $title . variable_get('clientside_validation_suffix', '');
if ($decimalpoint == '.') {
$js_rules[$name]['number'] = TRUE;
$variables = array(
'message' => '!title field accepts only numbers (use a \'.\' as decimal point).',
'placeholders' => array('!title' => $title),
'message' => empty($message) ? '!title field accepts only numbers (use a \'.\' as decimal point).' : $message,
'placeholders' => empty($message) ? array('!title' => $title) : array(),
'error_type' => 'number',
'element_name' => $name,
);
......@@ -360,8 +360,8 @@ function _clientside_validation_set_number_decimal($name, $title, $decimalpoint,
else {
$js_rules[$name]['numberDE'] = TRUE;
$variables = array(
'message' => '!title field accepts only numbers (use a \',\' as decimal point).',
'placeholers' => array('!title' => $title),
'message' => empty($message) ? '!title field accepts only numbers (use a \',\' as decimal point).' : $message,
'placeholers' => empty($message) ? array('!title' => $title) : array(),
'error_type' => 'number',
'element_name' => $name,
);
......@@ -896,12 +896,12 @@ function _clientside_validation_set_checkboxgroup_minmax($name, $title, $id, &$j
/**
* Set validation rule for email fields.
*/
function _clientside_validation_set_email($name, $title, &$js_rules) {
function _clientside_validation_set_email($name, $title, &$js_rules, $message = '') {
$title = variable_get('clientside_validation_prefix', '') . $title . variable_get('clientside_validation_suffix', '');
$js_rules[$name]['email'] = TRUE;
$variables = array(
'message' => 'The value in !title is not a valid email address.',
'placeholders' => array('!title' => $title),
'message' => empty($message) ? 'The value in !title is not a valid email address.' : $message,
'placeholders' => empty($message) ? array('!title' => $title) : array(),
'error_type' => 'email',
'element_name' => $name
);
......@@ -911,11 +911,12 @@ function _clientside_validation_set_email($name, $title, &$js_rules) {
/**
* Set validation rule for url fields.
*/
function _clientside_validation_set_url($name, $title, &$js_rules) {
function _clientside_validation_set_url($name, $title, &$js_rules, $message = '') {
$title = variable_get('clientside_validation_prefix', '') . $title . variable_get('clientside_validation_suffix', '');
$js_rules[$name]['url'] = TRUE;
$variables = array(
'message' => 'The value in !title is not a valid url.', 'placeholders' => array('!title' => $title),
'message' => empty($message) ? 'The value in !title is not a valid url.' : $message,
'placeholders' => empty($message) ? array('!title' => $title) : array(),
'error_type' => 'url',
'element_name' => $name
);
......
......@@ -110,24 +110,24 @@ function _clientside_validation_set_fapi_validation($element, $rule, $params, &$
break;
case 'fapi_validation_rule_numeric':
_clientside_validation_set_number_decimal($name, $title, '.', $js_rules);
_clientside_validation_set_number_decimal($name, $title, '.', $js_rules, $message);
break;
case 'fapi_validation_rule_email':
_clientside_validation_set_email($name, $title, $js_rules);
_clientside_validation_set_email($name, $title, $js_rules, $message);
break;
case 'fapi_validation_rule_length':
if (count($params) == 1) {
_clientside_validation_set_minmaxlength($name, $title, '', $params[0], $js_rules);
_clientside_validation_set_minmaxlength($name, $title, '', $params[0], $js_rules, $message);
}
elseif (count($params) == 2) {
_clientside_validation_set_minmaxlength($name, $title, $params[0], $params[1], $js_rules);
_clientside_validation_set_minmaxlength($name, $title, $params[0], $params[1], $js_rules, $message);
}
break;
case 'fapi_validation_rule_url':
_clientside_validation_set_url($name, $title, $js_rules);
_clientside_validation_set_url($name, $title, $js_rules, $message);
break;
case 'fapi_validation_rule_chars':
_clientside_validation_set_specific_values($name, $title, $params, $js_rules);
_clientside_validation_set_specific_values($name, $title, $params, $js_rules, $message);
break;
case 'fapi_validation_rule_decimal':
if (count($params) == 2) {
......
Supports Markdown
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