Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

Commit

Permalink
[BUGFIX] Handle multiple occurrences of messages markers in JavaScript
Browse files Browse the repository at this point in the history
The message template of a field can be filled with the same marker
several times: every occurrence should be replaced.

Example:

```
messageTemplate = <span class="#TYPE#" data-#TYPE#="bar">#FIELD#</span>
```
  • Loading branch information
romm committed Oct 17, 2017
1 parent f221822 commit 12ac670
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Resources/Public/JavaScript/Field/Formz.Field.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ Fz.Field = (function () {
for (var name in messages[validationRuleName]) {
if (messages[validationRuleName].hasOwnProperty(name)) {
messageListContainerElement.innerHTML += messageTemplate
.replace('#FIELD#', this.getName())
.replace('#FIELD_ID#', Fz.camelCaseToDashed('fz-' + this.getForm().getName() + '-' + this.getName()))
.replace('#VALIDATOR#', Fz.camelCaseToDashed(validationRuleName))
.replace('#TYPE#', type)
.replace('#KEY#', name)
.replace('#MESSAGE#', messages[validationRuleName][name]);
.split('#FIELD#').join(this.getName())
.split('#FIELD_ID#').join(Fz.camelCaseToDashed('fz-' + this.getForm().getName() + '-' + this.getName()))
.split('#VALIDATOR#').join(Fz.camelCaseToDashed(validationRuleName))
.split('#TYPE#').join(type)
.split('#KEY#').join(name)
.split('#MESSAGE#').join(messages[validationRuleName][name]);
}
}
}
Expand Down

0 comments on commit 12ac670

Please sign in to comment.