HTML form name array parsing in Pyramid (Python)

纵然是瞬间 提交于 2019-12-19 09:24:02

问题


Is there any way for Pyramid to process HTML form input which looks like this:

<input type="text" name="someinput[]" value="" />

or even more usefully:

<input type="text" name="someinput[0][subelement1]" value="" />
<input type="text" name="someinput[0][subelement2]" value="" />
<input type="text" name="someinput[1][subelement1]" value="" />
<input type="text" name="someinput[1][subelement2]" value="" />

...and access that data easily (e.g. via a dict)?

Any help would be much appreciated!

EDIT: to make it clearer, what I need is the ability to have a form where a user can add as many 'instances' of a group of input elements, e.g. adding between 1 and n users, each containing a firstname, lastname, username (or something like that).


回答1:


One solution would be to use peppercorn. Although it does not support the syntax you're looking for, it will let you send structured data to your Pyramid application through the use of forms. A more casual description exists too.



来源:https://stackoverflow.com/questions/6734702/html-form-name-array-parsing-in-pyramid-python

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