Ah.  That explains one mystery.  I knew about setting the formname in the 
SQLFORM call, but I had not noticed I needed to pass it in the "validate" 
method as well.

I think perhaps Niphlod is right in that I should look towards 
SQLFORM.factory since this seems to be trending away from the average use 
of SQLFORM.

That form code is pretty hard to follow. If you start with an SQLFORM and 
call validate(), the call goes to FORM.validate() which then calls 
self.accepts(), meaning SQLFORM.accepts() in this case, which then calls 
FORM.accepts().  We do this kind of stuff all the time in Smalltalk but I'm 
not accustomed to seeing it in Python!

-- Joe

On Sunday, August 18, 2013 9:19:28 PM UTC-7, Anthony wrote:
>
> Also, as a general note, the automatic form names will be different for 
> create vs. update forms, but you can control that by specifying your own 
> form name via the "formname" argument to accepts/validate/process.
>
> Anthony
>
> On Sunday, August 18, 2013 6:06:20 PM UTC-7, Niphlod wrote:
>>
>> Given that you are pretty down the line of deciding what table needs to 
>> be "touched", you should just write a wrapper that either inserts a record 
>> on work_table and let the users edit it or that it copies the values from 
>> the ro_table to the work_table as defaults, and then prepare a "prefilled" 
>> form with fields from the work_table.
>>
>> pseudo_code
>> if user_selected_ro:
>>      values = db(db.ro_table.id == user_selected_ro).select().first()
>>      .....
>>      for f in db.work_table.fields:
>>          db.work_table[f].default = values[f]
>> form = SQLFORM(db.work_table)
>> .....
>>
>> Given that some of the fields are calculated, you may want to use 
>> SQLFORM.factory as well, because you'd likely want to manage the inserted 
>> data a little bit before the insertion on the work_table.
>>
>>

-- 

--- 
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.

Reply via email to