mattupstate/flask-security — pull request #58 by eskil (2013-01-04 06:09:36+00:00)
Title: Configurable forms

Hi Matt,

I've taken a stab at fixing https://github.com/mattupstate/flask-security/issues/49. This adds a set of functions like the context processor decorators. Each decorator specifies a function that returns the ``Form`` class to use for that particular view. App writers can then inherit from the existing form classes and extend with with WTForms fields as needed.

Example

```
# Given a User model with extra columns:
# first_name = Column(String(120))
# last_name = Column(String(120))

security = Security(app, user_datastore)

from flask_security.forms import RegisterForm

class ExtendedRegisterForm(RegisterForm):
first_name = TextField('First Name', [Required()])
last_name = TextField('Last Name', [Required()])

@security.register_form
def security_register_form():
return ExtendedRegisterForm

```

I specifically did not go the ```model_form``` route. From earlier attempt I found that it got more verbose when using as opposed to this.

Let me know if anything needs changing.