1

我正在使用formencode在我的 Pylons 应用程序中验证和提交表单。文档说它也可以用于生成表单,但没有任何示例。我什至找到了旧的话题,它说可以用

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

但是对于最新版本的formencode,它不起作用。

那么,请有人帮忙,我怎样才能使用最简单的表单模式生成 HTML?

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)
4

2 回答 2

1

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.

于 2010-07-11T18:44:02.950 回答
0

zifot 关于formencode 的说法是正确的。我只想补充一点,你应该看看 FormAlchemy 和 Sprox,这两个库是为从数据库模式生成表单而构建的。

于 2010-07-11T19:14:36.277 回答