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
signature.asc
Description: This is a digitally signed message part

