You are right there's no easy way to do it.
Turns out to stick with SQLFORM instead.

SQLFORM.factory for inserts are great, but not updates.

Thanks Richard!

On Dec 24, 6:30 am, Richard Vézina <ml.richard.vez...@gmail.com>
wrote:
> I think what you try to do is a kind of bulk insert or bulk update...
>
> I write my own bulk update function with a SQLTABLE table displaying the
> rows that will be update and a SQLFORM.factory form for handling the
> submission... Then you just manually process records base on the id of the
> rows you have selected...
>
> In that particular case of use of I had to find a way to make sure no
> records change of state between the time the form is displayed to the end
> user and the time he finally submit the form... I calculate a md5_hash for
> every rows then pass it to the form as a hidden field then check for every
> row if there were still the same hash before actually update the row...
>
> It works for me this way cause I had really simple update to make to all
> the records (just one field was updated will the same value for every
> record).
>
> You may search the mailing-list Massimo had propose something ressembling
> to this (I can't find it back) :
>
> rows = db(...).select(db...)
>
> form = SQLFORM.factory(*[Field(f+'_%s'%r.id, default=r[f]) for r in rows
> for f in r])
> if form.process().accepted:
>     for key,value in form.vars.items():
>            db(db[request.args(0)].id==key[3:]).update(reviewed_by = 1)
>            db.commit()
>
> There is no easy way to do what you want to do I think... At least there is
> noting as easy as form = crud.create_bulk(...) or crud.update_bulk(...)
>
> Richard
>
>
>
>
>
>
>
> On Fri, Dec 23, 2011 at 2:00 AM, lyn2py <lyn...@gmail.com> wrote:
> > It is simple to edit or update if it only involves one table
> > (SQLFORM).
>
> > However I have combined tables into a form using SQLFORM.factory and
> > also SQLFORM.factory + append fields
>
> > How should I go about updating a form with combined tables (+ append
> > fields)?
>
> > I have read
>
> >http://web2py.com/books/default/chapter/29/7#SQLFORM-and-insert/updat...
> > but it doesn't cover how to use SQLFORM.factory with record edits.
>
> > Thanks!

Reply via email to