Do not use CRUD. Use SQLFORM instead. form = SQLFORM(...) if form.process(dbio=False).accepted: if form.record.field_X == 'B': del form.vars['field_X'] form.record.update_record(**form.vars)
On Monday, 22 July 2013 05:26:41 UTC-5, lesssugar wrote: > > Hi, Massimo, > > thanks for the solution, it looks totally fine but I just wasn't clear > enough on this - my bad. > > The thing is I'm using crud.update() to generate the form I described > earlier. How would I adapt your code to crud? In my case I must influence > crud.update() so it performs the additional action (checking field_X) * > during* the update. I could of course use "onaccept" but it's triggered > after the update nad before redirect, which is sort of going around the > problem. > > > > On Monday, July 22, 2013 12:20:38 AM UTC+2, Massimo Di Pierro wrote: >> >> How about this? >> >> record = db.table[id] >> newfieldvalues = {'field_X':'value', ....} >> if record.field_X == 'B': del newfieldvalues['field_X'] >> record.update_record(**newfieldvalues) >> >> >> if db.table[id].field_X == A: >> #perform full update >> elif db.table[id].field_X == B: >> #update all fields except field_X >> >> >> >> On Sunday, 21 July 2013 08:11:44 UTC-5, lesssugar wrote: >>> >>> When going to update page I would like to check the value of field_X. >>> Then, depending on its current value, field_X should be updated along with >>> the other fields OR be excluded from upload: >>> >>> if db.table[id].field_X == A: >>> #perform full update >>> elif db.table[id].field_X == B: >>> #update all fields except field_X >>> >>> Not sure how to achieve this. Ideas? >>> >> -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.