Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML form name array parsing in Pyramid (Python)

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

like image 403
johneth Avatar asked Oct 15 '25 04:10

johneth


1 Answers

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.

like image 60
Chris McDonough Avatar answered Oct 17 '25 21:10

Chris McDonough



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!