yes, I see what you mean... that is interesting... Now, you have me
wanting to look into that too ;) Could be very useful as a plugin (or
ready made snippet of code), you are right with that.

Mart :)

On Jan 17, 1:08 pm, Richard Vézina <ml.richard.vez...@gmail.com>
wrote:
> Not exactly what I seaching for...
>
> As far as I understand... It only let you simplified code by isolated
> repetitive piece of model code. Since it's only create one table I can't
> have a normalized schema.
>
> I would do something like this :
>
> http://charlie.griefer.com/blog/index.cfm/2009/9/17/jQuery--Dynamical...
> see
> demo link in page
>
> This snippet seems much more interresting since you can even pick the type
> of input field you want to create 
> :http://www.randomsnippets.com/2008/02/21/how-to-dynamically-add-form-...
> second
> example
>
> This can let me insert the other form field (or subform) in my first form
> then I could use jQuery to add more row in my second table or subform... But
> I have 2 submit buttons and I will have to set the ID of the first form as a
> foreigh key for the second form or table manually 
> :http://www.mail-archive.com/web2py@googlegroups.com/msg31293.html
>
> Richard
>
> On Mon, Jan 17, 2011 at 8:46 AM, Richard Vézina <ml.richard.vez...@gmail.com
>
>
>
>
>
>
>
> > wrote:
> > 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

Reply via email to