level12 / keg-elements

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Render wtforms FormField

mtbrock opened this issue · comments

FormField lets you embed a form in another form. For example, if you have an Address form and a Person form, you can add address = FormField(AddressForm) to the Person form and have Address fields included in the Person form.

We should modify the render_field macro to check for FormFields and render that appropriately. You can loop through the fields of FormField the same way you would loop through a Form.

It might also be nice to add some customization to the ModelForm (and possibly a custom FormField) to allow automatically populating the correct model object for each FormField. I believe this would have to be done manually without some customization but I'm in the middle of implementing this on one of our projects so I'll have more details on that soon, as well as some sample code.