Commit 1213cdee authored by Jelle Sebreghts's avatar Jelle Sebreghts
Browse files

Issue #1804784 by SeanBannister: Fixed Bug with support for Field Validation Tokens.

parent 721700e9
/*jshint strict:true, browser:true, curly:true, eqeqeq:true, expr:true, forin:true, latedef:true, newcap:true, noarg:true, trailing: true, undef:true, unused:true */
/*global Drupal: true, jQuery: true*/
/**
* File: clientside_validation_field_valdiation.js
* Version: 7.x-1.x
* Description: Replace field validation's error message placeholders with their values.
* Author: Attiks
* Language: Javascript
* Project: clientside_validation_field_valdiation
* @module clientside_validation
*/
(/** @lends Drupal */function ($) {
"use strict";
/**
* Drupal.behaviors.clientsideValidationFieldValidation.
*
* Attach behavior for replacing field validation's error message placeholders
* with their values.
*/
Drupal.behaviors.clientsideValidationFieldValidation = {
attach: function () {
$(document).bind('clientsideValidationInitialized', function(){
for (var formid in Drupal.myClientsideValidation.validators) {
if (Drupal.myClientsideValidation.validators.hasOwnProperty(formid)) {
Drupal.myClientsideValidation.validators[formid].settings.showErrors = function (errorMap, errorList) {
this.defaultShowErrors();
for (var index in errorList) {
var label = this.errorsFor( errorList[index].element );
if ( label.length ) {
label.html(label.html().replace("[value]", $(errorList[index].element).val()));
}
}
}
}
}
});
}
};
})(jQuery);
......@@ -9,6 +9,8 @@
function clientside_validation_field_validation_clientside_validation_form_alter(&$form, &$form_state, &$js_rules) {
$field_rules = array();
clientside_validation_field_validation_find_rules($form, $field_rules);
if (!empty($field_rules)) {
$form['#attached']['js'][] = drupal_get_path('module', 'clientside_validation_field_validation') . '/clientside_validation_field_validation.js';
foreach ($field_rules as $rule) {
$element = &$form;
// Field validation 1.x
......@@ -38,6 +40,7 @@ function clientside_validation_field_validation_clientside_validation_form_alter
}
}
}
}
}
function clientside_validation_field_validation_find_rules($form, &$field_rules) {
......
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