On Wed, 2011-11-16 at 15:36 -0500, Richard Vézina wrote: > Man! > > > I think you got a nice solution for this exact problem... > > > I had tried with jQuery in the pass to manage this by duplicating the > field that I want to bunch insert for... It was working but was > breaking the workflow of form validation if I remember... Web2py has > change a lot since then and I don't know if Massimo has not resolved > this issue (confirmation needed!!). > > > But I think what you suggest is pretty neath approach and easy to > implement... > > > Web2py guru?? > > > I suspect that you want to make insertion in multiple table...
Yep, but I also want to have some control over this.. since whether to insert/update a record is determined by other form fields, the number of tables is variable and possibly there are clashing field names, ... > You may be interrested by this : > > > http://web2py.com/book/default/chapter/07?search=SQLFORM.factory#One-form-for-multiple-tables Tried that, but «This only works when the tables don't have field names in common.». Anyways, I managed to find a way that seems to work, in order to merge SQLFORMs for multiple tables, adding a "namespace" in front of field name, and then stripping it before doing inserts. See relevant parts from the controller source code here: http://pastebin.com/V1xwcjAg This of course could be extended to build a tree from ``form.vars``, instead of just a ``dict``-of-``dict``s (maybe by exploding ``my[var][name]``-style subscripted vars), etc.. -- Samuele ~redShadow~ Santi ---------------------------------------------------------------- redshadow[at]hackzine.org - redshadowhack[at]gmail.com Blog: http://hackzine.org GPG Key signature: 050D 3E9F 6E0B 44CE C008 D1FC 166C 3C7E EB26 4933 ---------------------------------------------------------------- /me recommends: Squadra Informatica - http://www.squadrainformatica.com ---------------------------------------------------------------- - Proud ThinkPad T-Series owner - Registered Linux-User: #440008 * GENTOO User since 1199142000 (2008-01-01) * former DEBIAN SID user ---------------------------------------------------------------- "Software is like sex: it's better when it's free!" -- Linus Torvalds
signature.asc
Description: This is a digitally signed message part