web2py custom form doesn't submit

ⅰ亾dé卋堺 提交于 2020-01-06 18:12:32

问题


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)

view:

{{=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


回答1:


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>

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.



来源:https://stackoverflow.com/questions/43303715/web2py-custom-form-doesnt-submit

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!