Found this :

http://code.google.com/p/django-dynamic-formset/

<http://code.google.com/p/django-dynamic-formset/>Richard

On Fri, Jan 21, 2011 at 3:34 PM, Richard Vézina <[email protected]
> wrote:

> Hello,
>
> Here a version 0.00001 pre pre before alpha [?]
> (see attachement)
>
> But it works...
>
> There is code in :
>
> layout.html in head : js that I move there to get debug web2py button (no
> view)
> default controller : register_new function and a couple of other functions
>
> default/register_new
>
> Add row button add all the rows you want. Fill it up submit... Go admin
> db.address see that there is a row for each added input for street and city.
>
> Didn't test it to much.
>
> I had to use request.vars to get street2, city2, etc. inputs that were
> filtered by .accept()
>
> Validators not working for the added inputs... If one input is fill for
> required field it will pass and null will be entered in db.address for empty
> input.
>
> Richard
>
>
>
> On Wed, Jan 19, 2011 at 10:21 AM, Richard Vézina <
> [email protected]> wrote:
>
>> If you move the script into the layout.html in the head it still works...
>> You can then remove the view /view/default/register.html_
>>
>> So you get access to admin, request, session, response button to see what
>> going. You can see that city2 vars is store in session for example.
>>
>> Richard
>>
>> On Wed, Jan 19, 2011 at 10:17 AM, Richard Vézina <
>> [email protected]> wrote:
>>
>>> For now only adding and removing city input. I clone city input retag
>>> id='city' to id='city2' for the first clone and so on. I change all the id
>>> attribute of other tag cloned like divs. I had a garbage can icon and make
>>> it mouseover. That it for now.
>>>
>>> Since I change the id of input to city2, city3 all those cloned input are
>>> not consider by the register controller for now. I have to figure out how
>>> _filter_fields works to modifying it (add regex hope it will work). Then I
>>> would like the controller to add as many rows in the "subform" or table2
>>> (address table) as there is cloned city input fields.
>>>
>>> If I am not changing the id of input it will not be w3c html compliant,
>>> but web2py will insert all the added input filled into city field of address
>>> table like this :
>>>
>>> |city1|city2|city3|etc|
>>>
>>> Not bad but not normalized schema and possibly problematic if length of
>>> city field is fixed or using to much space for nothing.
>>>
>>> If you feel that you know how to modify register function I will be glad
>>> for your help.
>>>
>>> When it read, we could had a new recipe into the book ;-)
>>>
>>> Richard
>>>
>>>
>>>
>>> On Wed, Jan 19, 2011 at 9:48 AM, mart <[email protected]> wrote:
>>>
>>>> Excellent! je prends le train, direction MTL, a tous les quelques mois
>>>> pour me rendre au bureau (peut-etre un peu moins souvent l'hiver ;) )
>>>>
>>>> SO, I have a question: Once, I use the button to add a field (which
>>>> does work well), what should be the expected back-end result? does one
>>>> of the tables get updated? or should a new table get generated based
>>>> on input type? How about a Field name? generic one name fits all (or
>>>> depends on type?)
>>>>
>>>> Mart :)
>>>>
>>>>
>>>>
>>>> On Jan 19, 9:12 am, Richard Vézina <[email protected]>
>>>> wrote:
>>>> > ;-) Originellement oui...
>>>> >
>>>> > I would tell you on the orther thread that I post this one... I will
>>>> do it
>>>> > just for the one that fall on the orther thread so they could keep
>>>> track...
>>>> >
>>>> > I continue today working on this.
>>>> >
>>>> > Richard
>>>> >
>>>> >
>>>> >
>>>> >
>>>> >
>>>> >
>>>> >
>>>> > On Wed, Jan 19, 2011 at 12:30 AM, mart <[email protected]> wrote:
>>>> > > Hey, es-tu de Montreal?
>>>> >
>>>> > > On Jan 18, 7:08 pm, Richard Vézina <[email protected]>
>>>> > > wrote:
>>>> > > > I forgot to paste :
>>>> >
>>>> > > > def register():
>>>> > > >     form=SQLFORM.factory(db.client, db.address, formstyle =
>>>> 'divs') #,
>>>> > > > table_name='dummy_name')
>>>> > > >     if form.accepts(request.vars):
>>>> > > >         id =
>>>> db.client.insert(**db.client._filter_fields(form.vars))
>>>> > > >         form.vars.client=id
>>>> > > >         id =
>>>> db.address.insert(**db.address._filter_fields(form.vars))
>>>> > > >         response.flash='Thanks for filling the form'
>>>> > > >     return dict(form=form)
>>>> >
>>>> > > > What to do for what in red?
>>>> >
>>>> > > > I think _filter_fields is the key of the problem...
>>>> >
>>>> > > > I didn't have a look to it actually...
>>>> >
>>>> > > > Richard
>>>> >
>>>> > > > On Tue, Jan 18, 2011 at 7:00 PM, Richard Vézina <
>>>> > > [email protected]
>>>> >
>>>> > > > > wrote:
>>>> > > > > Hello Massimo,
>>>> >
>>>> > > > > I am trying to insert data in 2 tables from one form... I would
>>>> like to
>>>> > > be
>>>> > > > > able to insert any number of rows or records in the subtable.
>>>> >
>>>> > > > > I build this test app (see attach)... All the work I did is
>>>> mostly in
>>>> > > > > /default/register.html where there is jQuery script that allow
>>>> adding
>>>> > > new
>>>> > > > > city input and delete new city input...
>>>> >
>>>> > > > > I built it from scratch for Web2py inspired by :
>>>> > > > >
>>>> http://charlie.griefer.com/blog/index.cfm/2009/9/17/jQuery--Dynamical.
>>>> > > ..
>>>> >
>>>> > > > > What should I do in register to allow the function to insert all
>>>> the
>>>> > > filled
>>>> > > > > city clone field??
>>>> >
>>>> > > > > Next step will be adapted my script that it manage all the
>>>> subform
>>>> > > columns
>>>> > > > > instead of only one.
>>>> >
>>>> > > > > Thanks.
>>>> >
>>>> > > > > Richard
>>>>
>>>
>>>
>>
>

<<330.gif>>

Reply via email to