New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better error messages for mdl-textfield #65
Better error messages for mdl-textfield #65
Conversation
This looks great. Let's get it implemented with mdl-textarea as well in this PR, so we can have one release with consistent support for error messages |
@@ -12,5 +18,15 @@ export default BaseComponent.extend({ | |||
], | |||
beforeMdlInit() { | |||
this.$('label.mdl-button').attr('for', this.get('_inputId')); | |||
} | |||
}, | |||
setValidity: observer('errorMessage', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please indicate that this is private (_setValidity
)
@mike-north thanks for the feedback, will roll with this and get it done by the weekend! |
This is great, looking forward to using it. To hijack this PR a bit: Would formatting ember-data error messages directly be something you are interested in supporting? For example, given {{mdl-textarea
label='Title'
value=post.title
errors=post.errors.title
}} Or maybe I should just use a sub-expression? |
Added integration tests for textarea Moved common input validations to base-input-component
@mike-north implemented the textarea part too, apologies for the delays. @alanpeabody, imho I don't think it is a good idea. Just pass in a computed property with the error, we can't favour one style of validations over another. |
@mike-north @kennethkalmer Any update if this will be merged or not? |
Looking forward for the merge. |
Better error messages for mdl-textfield
I added support for binding
errorMessage
to something coming from outside the component. Lets say you have existing validations or server-side validations and want to provide feedback to the user, the simplepattern
approach provided by theHTMLInputElement
doesn't work.This approach simply observes the
errorMessage
property, sanitises the value slightly, and calls theHTMLInputElement
'ssetCustomValidity
, which in turns triggers MDL to do its thing and apply the correctis-invalid
class to the wrapping div...Pending initial feedback I'll get this implemented on
{{mdl-textarea}}
too.