indexiatech / ember-forms

Smart, Intuitive forms for Ember.js styled with Bootstrap, Multi layouts and Validation support.
http://indexiatech.github.io/ember-forms
Apache License 2.0
218 stars 45 forks source link

adding support for Ember-Data style errors #67

Closed Emerson closed 9 years ago

Emerson commented 9 years ago

Hey @asaf,

Migrating to ember-data and ember-cli on my project and noticed that the errors were not displaying properly. I was seeing [object object] in my templates instead of the actual error text.

I'm not sure if this is a new thing, but it looks like the DS.Errors array now has an object for each field error instead of plain text. Assuming we have a post that has a validation error on the title, it would look like this:

// Assuming we've tried to save the record and our server returned an error on the title...
var post = this.get('currentModel');
post.get('errors.title')
=> [{message: 'Title cannot be blank', attribute: 'title'}]

This small change appears to fix the problem.

asaf commented 9 years ago

@Emerson When this is happening ? I cannot reproduce..

piotrpalek commented 9 years ago

I also noticed this behavior, and I posted an issue to ember data: https://github.com/emberjs/data/issues/2604. There's an jsbin example you can look at.

Basically when you use errorsFor or errors.get("[attributeName]") you don't get an array with error messages, you get an array with objects just like @Emerson posted above.

josemarluedke commented 9 years ago

I would love to see this merged!

prikhi commented 9 years ago

Any plan on supporting DS.Errors? Or does anyone have a workaround that doesn't involve modifying ember-forms code?

asaf commented 9 years ago

@Emerson Thanks, @prikhi pushed!