views:

47

answers:

2

I'm using formencode for validating and submitting forms in my Pylons application. The documentation says that it can be used also for generating forms, but there is no any example. I even found the old topic which says it can be done with

form = HTMLForm(form_template, FormSchema)
form.render()

but for the latest version of formencode it doesn't work.

So, someone please help, how can I generate a HTML using the simplest form Schema?

class LoginForm(formencode.Schema):
    allow_extra_fields = True
    filter_extra_fields = True
    email = formencode.validators.String(not_empty=True)
    password = formencode.validators.String(not_empty=True)
+1  A: 

Formencode library doesn't generate html for forms.

The code you are referring to uses formencode.htmlform module which no longer exists as it was removed in 1.1 release because, as author said, it was dumb. :)

I think you may have mistaken that kind of functionality with different feature of this lib, namely filling form values after unsuccessful submission which is realised by formencode.htmlfill module.

zifot
Thanks for answer, I'm trying to use Pylons after Django, so all the time I think it should be simple :)
Enchantner
A: 

What zifot said about formencode was spot on. I would only add that you should look at FormAlchemy and Sprox, two libraries built to generate forms from database schemas.

yarmiganosca
I'm using MongoKit, so almost all form generation engines won't help because of different model description.
Enchantner