Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add coerce argument to SelectField in model_form #34

Closed
ddorian opened this issue Feb 11, 2013 · 3 comments
Closed

Add coerce argument to SelectField in model_form #34

ddorian opened this issue Feb 11, 2013 · 3 comments
Milestone

Comments

@ddorian
Copy link

ddorian commented Feb 11, 2013

For example if you have a intfield with choices, it shows an error

@rozza
Copy link
Contributor

rozza commented May 2, 2013

Pull requests welcome! Or can you clarify..

@ddorian
Copy link
Author

ddorian commented May 2, 2013

I looked at this and couldn't find an automatic way to fix it. To reproduce is simple:

  1. Create document with IntField(with_choices)
  2. Create model_form from document.
  3. Submit the form.

You need to make:

class DOC(db.Document):
     CHOICES = ((1,'string'),(2,'another string'))
     thefield = IntField(choices=CHOICES)

DocumentForm = model_form(DOC, field_args={
    'thefield': {'coerce': int}
})

Basically the resulting SelectField() must have (coerce=int) but i don't know how to make it automatic for booleans,floats etc. (or it doesn't have to be automatic?)

@rozza
Copy link
Contributor

rozza commented May 3, 2013

Added in 0.7

@rozza rozza closed this as completed May 3, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants