我正在關注Web2py的關於SQLFORM的HTML書籍。 http://web2py.com/books/default/chapter/29/07#SQLFORMHTML2中的Web2py SQLFORM
但是,我似乎無法弄清楚。我已將隱藏字段name="_formname"
及其值設置爲test
。該表格似乎沒有被處理。這裏是我的代碼:
的test.html:
<form action="" method="post">
<ul>
<li>Your name is <input name="name" /></li>
</ul>
<input type="submit" />
<input type="hidden" name="_formname" value="test" />
</form>
控制器/默認/ test.py:
def test():
form = SQLFORM(db.person)
if form.process(formname='test').accepted:
session.flash = T('Succeeded.')
redirect(URL('index'))
elif form.errors:
response.flash=T('Form has errors.')
return dict()
模型/ db.py:
db.define_table('person',
Field('name', requires=IS_NOT_EMPTY()))
什麼是你的test.html文件(圖) – chespinoza