-
-
Save jhliberty/0dd9fe129c9b30dad4b967811fb5d948 to your computer and use it in GitHub Desktop.
UI Field helper {{ui-field}}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
classNames: ['field'], | |
classNameBindings: ['is_error:error'], | |
model: null, // Model object being passed in | |
property: null, // The specific property on the model to look for | |
submitted: false, | |
show_error: true, | |
didInitAttrs() { | |
Ember.defineProperty(this, 'is_error', Ember.computed('submitted',`model.validations.attrs.${this.get('property')}.isTruelyValid`, function() { | |
if (this.get('submitted')) { | |
let valid = this.get(`model.validations.attrs.${this.get('property')}.isTruelyValid`); | |
if (typeof valid === "boolean") { | |
this.set(`model.validations.attrs.${this.get('property')}.fieldObserved`, true); | |
return !valid; | |
} | |
} | |
return false; | |
})); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment