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

You may be interrested by this :

http://web2py.com/book/default/chapter/07?search=SQLFORM.factory#One-form-for-multiple-tables



Richard



On Wed, Nov 16, 2011 at 3:12 PM, ~redShadow~ <redsha...@hackzine.org> wrote:

> For some reason, I need to simultaneously update a bunch of records
> together in the same form. Specifically, records come from different
> tables but field names sometimes overlaps, this not allowing to simply
> merge the standard CRUD SQLFORMs.
>
> I like a feature in the Drupal Forms API that's specifically to solve
> any sub-forming problem: tree placement of fields.
>
> So, when you create a form like this:
>
>    group0
>      element0
>      element1
>    group1
>      element0
>      element1
>      element2
>      group2
>        element0
>        element1
>
> then the form generator creates fields named like:
>
>    edit[group0][element0]
>    edit[group0][element1]
>    edit[group1][element0]
>    edit[group1][element1]
>    edit[group1][element2]
>    edit[group1][group2][element0]
>    edit[group1][group2][element1]
>
> grouped inside some <fieldset>s.
>
> When the form gets submitted, vars are split (also by taking advantage
> of how php parses query strings recursively) in a structure like this:
>
>    {
>      'group0' : {
>        'element0' : '..some value..',
>        'element1' : '..some value..',
>      },
>      'group1' : {
>        'element0' : '..some value..',
>        'element1' : '..some value..',
>        'element2' : '..some value..',
>        'group2' : {
>          'element0' : '..some value..',
>          'element1' : '..some value..',
>        }
>      }
>    }
>
> So, extracting trees of values becomes quite easy.
>
> Now the question is: is there anything like this inside web2py?
> I looked for it in the book and in the code, but didn't find anything..
>
> --
> 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
>
>

Reply via email to