When calling replacePlaceholdersInMessage(), it now will first look for a data attribute on the field, data-validator-placeholder, before falling back to the original name.
This allows for something other than the field name to be displayed in error messages.
Add a way to modify the message placeholder text.
When calling `replacePlaceholdersInMessage()`, it now will
first look for a data attribute on the field
(`data-validator-placeholder`) before falling back to the original
Thanks for this! I think this brings about a potentially larger discussion. I've been thinking for a while about allowing more configuration to be set through data-foo type attributes so it's easier to customise. Would love to hear people's thoughts about using data attributes more vs configuring through JS.
@jackfranklin I had originally planned on adding it directly in the JS, but decided against it mostly for the added ease of using a template engine to fill the data-attribute in on the server side.
However, I feel that only allowing configuration through data attributes could quickly make the HTML messy. Maybe a hybrid would be best (like Twitter Bootstrap's JS stuff), but this adds some extra complexity. At least it would allow people to choose what is best for them.
@rsenk330 you share the same concerns as me. I like this approach but my concern is that if we do this for this one setting it's a bit inconsistent.
I think we either make more use of data attributes or implement this change (I like the idea behind this PR) but setting the value via JS.