Add a way to modify the message placeholder text #3

Open
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants

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.

@rsenk330 rsenk330 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
`name`.
24c3286
Owner

jackfranklin commented Jan 16, 2013

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.

Owner

jackfranklin commented Jan 17, 2013

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment