pombreda / formalchemy

Automatically exported from code.google.com/p/formalchemy
MIT License
0 stars 0 forks source link

FieldSet need an add_error method #22

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When using a global_validator, it's hard to append an error to the field
itself.

what i do is adding a add_error method to my FieldSet class like:

class MyFieldSet(FieldSet):

  def add_error(self, field, error):
        self.render_fields[field.name].errors.append(error)

I like to see that in FA itself 

Original issue reported on code.google.com by gael.pas...@gmail.com on 5 Aug 2008 at 5:23

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
since you already have a reference to the field, just do

field.errors.append(error)

Original comment by jbel...@gmail.com on 5 Aug 2008 at 6:43

GoogleCodeExporter commented 9 years ago
i'm ok. but self.myfield.errors.append don't work in global_validator for me.

Here is the problem:

(...)controllers/inscription.py(12)validator()
(Pdb) self.fields['USR_Email'] is self.render_fields['USR_Email']
False

So if i add an error at this time with self.USR_Email.error.append('blah') the 
error
is never render.

Original comment by gael.pas...@gmail.com on 5 Aug 2008 at 7:16

GoogleCodeExporter commented 9 years ago
you are right...  I will think about the best way to solve this.  The fields / 
render_fields distinction is confusing.

Original comment by jbel...@gmail.com on 5 Aug 2008 at 7:47

GoogleCodeExporter commented 9 years ago
r400 makes fs.[fieldname] look it up in .render_fields first, then .fields 
(renamed 
to ._fields) if not found.  I think this will be more intuitive all around, 
besides 
making field.errors.append(error) work for you now.

Original comment by jbel...@gmail.com on 5 Aug 2008 at 9:17

GoogleCodeExporter commented 9 years ago

Original comment by jbel...@gmail.com on 5 Aug 2008 at 9:18