Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent validators from getting inserted twice #1099

Merged
merged 1 commit into from
Oct 27, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion flask_admin/contrib/mongoengine/form.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from copy import deepcopy

from mongoengine import ReferenceField, ListField
from mongoengine.base import BaseDocument, DocumentMetaclass, get_document

Expand Down Expand Up @@ -68,7 +70,8 @@ def convert(self, model, field, field_args):
}

if field_args:
kwargs.update(field_args)
# prevent modification of self.form_args
kwargs.update(deepcopy(field_args))

if field.required:
kwargs['validators'].append(validators.InputRequired())
Expand Down
5 changes: 4 additions & 1 deletion flask_admin/contrib/sqla/form.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import warnings

from copy import deepcopy

from wtforms import fields, validators
from sqlalchemy import Boolean, Column

Expand Down Expand Up @@ -147,7 +149,8 @@ def convert(self, model, mapper, prop, field_args, hidden_pk):
}

if field_args:
kwargs.update(field_args)
# prevent modification of self.form_args
kwargs.update(deepcopy(field_args))

# Check if it is relation or property
if hasattr(prop, 'direction'):
Expand Down