def test_nested_ajax_refs():
    (app, db, admin) = setup()

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

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

    class Model1(db.Document):
        test1 = db.StringField(max_length=20)
        nested = db.EmbeddedDocumentField(Nested)
    view1 = CustomModelView(Model1, form_subdocuments={'nested': {'form_ajax_refs': {'comment': {'fields': ['name']}}}})
    form = view1.create_form()
    eq_(type(form.nested.form.comment).__name__, 'AjaxSelectField')
    ok_(('nested-comment' in view1._form_ajax_refs))
def test_nested_ajax_refs():
    (app, db, admin) = setup()

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

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

    class Model1(db.Document):
        test1 = db.StringField(max_length=20)
        nested = db.EmbeddedDocumentField(Nested)
    view1 = CustomModelView(Model1, form_subdocuments={'nested': {'form_ajax_refs': {'comment': {'fields': ['name']}}}})
    form = view1.create_form()
    eq_(type(form.nested.form.comment).__name__, 'AjaxSelectField')
    ok_(('nested-comment' in view1._form_ajax_refs))