Thanks Mart... I read back my mail and my english was terrible. ;-) I thought about it after sent the mail and I realise that subform seems what I was searching for.
I will try what you propose and give feedback here. Richard On Sun, Jan 16, 2011 at 10:43 PM, mart <msenecal...@gmail.com> wrote: > You know, I discovered a week or 2 ago a way to make a form appear to > have sub-forms (or sub-templates). Massimo's 'Audit Trail' (i think I > saw it on web2pyslices) serves this purpose extremely well. To that, > it becomes very easy to write scripts to generate all sorts of > combinations of tables that exist to those that can be generated > dynamically. Anyways, from the Audit trail idea, I made a "requests > app", that serves many different categories and types of requests, > where forms can be created/generated on the fly. > > If I were doing something like you described, I would probably try > something like this > > test_1=db.Table(None,'test_1', > Field('results','??????') > Field('whomadethetest','string'), > Field('date','date')) > > test_2=db.Table(None,'test_2', > Field('results','??????') > Field('whomadethetest','string'), > Field('date','date')) > > then you could do this (or have scripts generate it): > > db.define_table('result', > Field('length','integer'), > Field('width','integer'), > Field('result','integer'), > test_1) > > or > > db.define_table('result', > Field('length','integer'), > Field('width','integer'), > Field('result','integer'), > test_1, > test2) > > or just the test results: > > db.define_table('result',test_1,test2) > > etc... > > Hope it helps, > Mart :) > > > On Jan 16, 4:38 pm, Richard Vézina <ml.richard.vez...@gmail.com> > wrote: > > Hello, > > > > Let me expose my problem. I have a test (experience test that I made in > lab) > > that I have to redo many time. At time point 1 there is only one result, > but > > at the other time point the is one more result to store each time. So at > > time point 2 there is two results, at time point 3 there is 3 results and > so > > on. > > > > Since the number of time point is not fixed I can create a given number > of > > columns to handle this probleme in a not normalized way. Say fill with > null > > the empty columns when the results are not available for a particular > record > > (or a given time point). > > > > To normalize the schema I can do : > > > > db.define_table('result', > > Field('length','integer'), > > Field('width','integer'), > > Field('result','integer')) > > > > db.define_table('test1', > > Field('results','list:integer result') > > Field('whomadethetest','string'), > > Field('date','date')) > > > > db.test1.results.requires = IS_IN_DB(db,'result.id',db. > > result._format,multiple=True) > > > > I could add my result one by one in the result table and then pick them > > up... > > > > But I would do something sexier then that. > > > > I would like to be able to add any number of record by adding the row of > > result table in the same form of test1 table. > > > > So my model should be : > > > > db.define_table('test1', > > Field('results','??????') > > Field('whomadethetest','string'), > > Field('date','date')) > > > > db.define_table('result', > > Field('length','integer'), > > Field('width','integer'), > > Field('result','integer'), > > Field('test1_id','db.test1') > > > > I have now a 1:n relation that is stored in result table. > > > > I would build a widget that let insert all the fields of an other table > row > > by row. So if I have one result generated at time point 1 there will be > one > > row in my form. But if I am a later time point there will have 2 rows for > > time point 2 and 3 for time point 3, etc. > > > > It could has a button to add more empty row that could be filled out. > > > > I read an search a lot. I found web2py_component that could be of some > > utility, but I am not sure since it seams to work with form in a global > > manner and not support field. SQLFORM.factory look the way to go before > > build the whole thing from scratch with form... > > > > If any of you have a android phone, I would make a form that looks and > works > > like the contact app. You can add any number of phone number for the same > > contact by pressing + button to add an other empty box (field). > > > > Do I must made a custom widget (widget seams to be reserved to a single > form > > processing), build custom form with helpers, or could SQLFORM.factory is > > enough??? > > > > Thanks > > > > Richard >