MongoEngine / flask-mongoengine

MongoEngine flask extension with WTF model forms support
Other
840 stars 256 forks source link

model_form fails for ListField of EmbeddedDocumentField declared using a string #62

Open mapio opened 11 years ago

mapio commented 11 years ago

This is probably related to #23. If the model contains a ListField wrapping an EmbeddedDocumentField and the latter is built from a string, then model_form fails.

The following code shows the problem

from flask.ext.mongoengine import MongoEngine
from flask.ext.mongoengine.wtf import model_form

db = MongoEngine()

class EmbedMe( db.EmbeddedDocument ):
    afield = db.StringField()

class Outer( db.Document ):
    embedded = db.ListField( db.EmbeddedDocumentField( EmbedMe ) )

class OuterString( db.Document ):
    embedded = db.ListField( db.EmbeddedDocumentField( 'EmbedMe' ) )

print model_form( Outer )
print model_form( OuterString )

I'm sure I can provide a failing test based on aa6f13ccffee6aa29a72c3fc0278fe83d66f4981 and the snippet above, but I'm not sure I can also provide a fix.

Dear @rozza, can you help?

rochacbruno commented 10 years ago

:+1: I am also having that issue

lafrech commented 8 years ago

I'm sure I can provide a failing test based on aa6f13c and the snippet above, but I'm not sure I can also provide a fix.

Failing test would be a good start. Thanks.