web2py自定义表单未提交 [英] web2py custom form doesn't submit

查看:47
本文介绍了web2py自定义表单未提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎无法使用以下代码提交表单:

I cant seem to submit my form with this code:

@auth.requires_login()
def index():
    db.post.answers.writable=False
    db.post.answers.readable=False
    form = SQLFORM(Post, formstyle='divs')
    if form.process().accepted:
        pass
    code.....
    return(form=form)

视图:

{{=form.custom.begin}}
<div class="chat-form">
    <textarea></textarea>
    <button>Send</button>
</div>
{{=form.custom.end}}

我的数据库为空,没有提交任何数据.请帮助问候

My db is empty with no data submitted.Please help Regards

推荐答案

您必须为HTML输入元素指定名称"属性,并且如果您将 SQLFORM 与web2py DAL一起使用模型,输入名称必须与模型字段的名称匹配.因此,在您显示的示例中,您将需要:

You must specify "name" attributes for your HTML input elements, and if you are using SQLFORM with a web2py DAL model, the input names must match the names of the model fields. So, in the example you have shown, you would need:

<textarea name="answers"></textarea>

没有名称"属性,浏览器将不会发送数据.而且,如果名称与 DAL 模型中的任何字段都不匹配,则web2py将对提交的数据不执行任何操作.

Without the "name" attribute, the browser will not send the data. And if the name does not match any fields in the DAL model, web2py will not do anything with the submitted data.

这篇关于web2py自定义表单未提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆