Skip to content

Commit

Permalink
Allow to use form_extra_fields
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosgalvez-tiendeo committed Feb 15, 2021
1 parent 46e82b1 commit 49a1ed8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion wtforms_appengine/ndb.py
Expand Up @@ -412,7 +412,7 @@ def model_fields(model, only=None, exclude=None, field_args=None,


def model_form(model, base_class=Form, only=None, exclude=None,
field_args=None, converter=None):
field_args=None, converter=None, extra_fields=None):
"""
Creates and returns a dynamic ``wtforms.Form`` class for a given
``ndb.Model`` class. The form class can be used as it is or serve as a base
Expand All @@ -439,6 +439,9 @@ def model_form(model, base_class=Form, only=None, exclude=None,
# Extract the fields from the model.
field_dict = model_fields(model, only, exclude, field_args, converter)

if extra_fields:
field_dict.update(extra_fields)

# Return a dynamically created form class, extending from base_class and
# including the created fields as properties.
return type(model._get_kind() + 'Form', (base_class,), field_dict)

0 comments on commit 49a1ed8

Please sign in to comment.