Skip to content

Commit

Permalink
Fixed #490. TextField with nullable column will return None
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjoes committed Apr 21, 2014
1 parent e09d4c0 commit 902b9c3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions flask_admin/contrib/sqla/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,11 @@ def conv_String(self, column, field_args, **extra):
field_args['choices'] = [(f, f) for f in column.type.enums]
return form.Select2Field(**field_args)

if column.nullable:
filters = field_args.get('filters', [])
filters.append(lambda x: x or None)
field_args['filters'] = filters

self._string_common(column=column, field_args=field_args, **extra)
return fields.TextField(**field_args)

Expand Down

0 comments on commit 902b9c3

Please sign in to comment.