TurboGears 1ΒΆ

Add the following to myapp/controllers.py, inside the Root class:

@expose()
@tg.validate(form=movie_form)
@tg.error_handler(movie)
def save_movie(self, **kw):
    return str(kw)

Also, update the existing movie method, change:

def movie(self):

to:

def movie(self, **kw):

We also need to update the form definition a little. Add this before the definition:

class FilteringSchema(twf.validators.Schema):
    filter_extra_fields = True
    allow_extra_fields = True

And change:

movie_form = twf.TableForm('movie_form', action='save_movie', children=[

To:

movie_form = twf.TableForm('movie_form', action='save_movie',
    validator=FilteringSchema, children=[

Previous topic

Building a Form with tw.forms

Next topic

TurboGears 2

This Page

Quick search