Skip to content

Instantly share code, notes, and snippets.

@mattbeedle
Created May 26, 2014 05:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattbeedle/c34058ab1b7882e5a1b8 to your computer and use it in GitHub Desktop.
Save mattbeedle/c34058ab1b7882e5a1b8 to your computer and use it in GitHub Desktop.
Getting ember-easyForm to display errors returned from 422 responses
# 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