python - Render an editable table using Flask, Jinja2 templates, then process the form data returned -



python - Render an editable table using Flask, Jinja2 templates, then process the form data returned -

i'm using flask , jinja2 , need create editable table multiple rows.

this table like:

and here's html that:

<form action="/support/team-members-update" method="post"> <table> <tbody><tr> <th>name</th> <th>id</th> <th>inbox share</th> </tr> <tr> <td>ben</td><td>55555</td><td><input type="text" name="share_55555" value="0"></td></tr> <tr> <td>steve</td><td>66666</td><td><input type="text" name="share_66666" value="1"></td></tr> <tr> <td>harry</td><td>77777</td><td><input type="text" name="share_77777" value="1"></td></tr> <tr> <td>sally</td><td>88888</td><td><input type="text" name="share_88888" value="1"></td></tr></tbody></table> <button type="submit">send</button> </form>

my current implementation in lua, i'm hard coding bunch of strings , connecting post info native lua types hand (fun!). if have to, can process form info hand in python well, imagine there's improve solution out there.

i have explored wtforms bit, haven't had much luck getting work correctly.

i did find fieldlist, seems deal list of same field, not multiple rows same exact fields.

i found tablewidget, documentation sparse , can't figure out how implement know if i'm looking do.

fieldlist work, need create list of formfield. specify formfield so:

class memberform(form): name = stringfield('name') member_id = stringfield('member_id') inbox_share = integerfield('inbox_share') # etc. class teamform(form): title = stringfield('title') teammembers = fieldlist(formfield(memberform))

teammembers iterable list can have many entries - render them out html table.

python flask jinja2 wtforms

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -