def test_subdocument_class_config():
    (app, db, admin) = setup()
    from flask_admin.contrib.mongoengine import EmbeddedForm

    class Comment(db.EmbeddedDocument):
        name = db.StringField(max_length=20, required=True)
        value = db.StringField(max_length=20)

    class Model1(db.Document):
        test1 = db.StringField(max_length=20)
        subdoc = db.EmbeddedDocumentField(Comment)

    class EmbeddedConfig(EmbeddedForm):
        form_columns = ('name',)
    view1 = CustomModelView(Model1, form_subdocuments={'subdoc': EmbeddedConfig()})
    form = view1.create_form()
    ok_(('name' in dir(form.subdoc.form)))
    ok_(('value' not in dir(form.subdoc.form)))
def test_subdocument_class_config():
    (app, db, admin) = setup()
    from flask_admin.contrib.mongoengine import EmbeddedForm

    class Comment(db.EmbeddedDocument):
        name = db.StringField(max_length=20, required=True)
        value = db.StringField(max_length=20)

    class Model1(db.Document):
        test1 = db.StringField(max_length=20)
        subdoc = db.EmbeddedDocumentField(Comment)

    class EmbeddedConfig(EmbeddedForm):
        form_columns = ('name',)
    view1 = CustomModelView(Model1, form_subdocuments={'subdoc': EmbeddedConfig()})
    form = view1.create_form()
    ok_(('name' in dir(form.subdoc.form)))
    ok_(('value' not in dir(form.subdoc.form)))