Created
May 26, 2014 05:24
-
-
Save mattbeedle/c34058ab1b7882e5a1b8 to your computer and use it in GitHub Desktop.
Getting ember-easyForm to display errors returned from 422 responses
This file contains hidden or 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
# This is a little ember easyform hack to make errors display when the form is | |
# submitted | |
Ember.EasyForm.Input.reopen | |
errorsChanged: (-> | |
@set('hasFocusedOut', true) | |
@showValidationError() | |
) | |
didInsertElement: -> | |
@addObserver("context.errors.#{@property}.@each", @, 'errorsChanged') | |
# This is a further little ember easyform hack to map the error message text to | |
# the message on the DS.Error object supplied by ember-data | |
# https://github.com/emberjs/data/pull/958 | |
Ember.EasyForm.Error.reopen | |
errorText: (-> | |
@get('errors.firstObject.message') or @get('errors.firstObject') | |
).property('errors.firstObject.message', 'errors.firstObject').cacheable() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment