Commit 5b9e3060 authored by Serge S. Koval's avatar Serge S. Koval

Fixed #329. Embedded document now supports field configuration properties

parent eb735767
......@@ -128,19 +128,15 @@ class CustomModelConverter(orm.ModelConverter):
return converter.convert(model, field.field, kwargs)
unbound_field = converter.convert(model, field.field, {})
kwargs = {
'validators': [],
'filters': [],
}
return InlineFieldList(unbound_field, min_entries=0, **kwargs)
@orm.converts('EmbeddedDocumentField')
def conv_EmbeddedDocument(self, model, field, kwargs):
kwargs = {
'validators': [],
'filters': [],
'widget': InlineFormWidget()
}
# FormField does not support validators
kwargs['validators'] = []
if 'widget' not in kwargs:
kwargs['widget'] = InlineFormWidget()
view = self._get_subdocument_config(field.name)
......
......@@ -474,3 +474,28 @@ def test_form_flat_choices():
form = view.create_form()
eq_(form.name.choices, [('a', 'a'), ('b', 'b'), ('c', 'c')])
def test_form_args_embeddeddoc():
app, db, admin = setup()
class Info(db.EmbeddedDocument):
name = db.StringField()
age = db.StringField()
class Model(db.Document):
info = db.EmbeddedDocumentField('Info')
timestamp = db.DateTimeField()
view = CustomModelView(
Model,
form_args= {
'info': {'label': 'Information'},
'timestamp': {'label': 'Last Updated Time'}
}
)
admin.add_view(view)
form = view.create_form()
eq_(form.timestamp.label.text, 'Last Updated Time')
# This is the failure
eq_(form.info.label.text, 'Information')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment