= Customising Fields = Here's an example of how we created a MoneyField that knows how to validate a currency value. Both {{{parser}}} and {{{formatter}}} are modules that we wrote to convert between formats. Our modules deal in dollars and cents but that's hidden from the application code. Note that the parser needs to be able to parse the output of the formatter: the field will be initialised with the formatter's output when it is rendered. It doesn't seem unreasonable to accept "$5.50" if that's the format that the application is presenting to the user. {{{#!python import parser, formatter class MoneyField(FloatField): def validate(self, form, s): s = s.strip() if not self.required and not s: return try: parser.money(s) except ValueError, e: raise FieldValidationError('Invalid value "%s" for money' % s) def get_merge_value(self, s): s = s.strip() if not self.required and not s: return return parser.money(s) def get_display_value(self, ctx, form): return formatter.money(self.get_value()) }}}