On Tuesday, January 29, 2013 4:40:04 AM UTC-5, AngeloC wrote:

> Hi Steve,
>
> Great suggestion, but the problem remains. How can I update a record that 
> I cannot select?
>
> The SQLFORM.factory way cannot permits to select a record to prepopulate 
> the forms, so you only can insert, but not update a record ...
>

I think you should be able to construct a dict (or Storage object) to pass 
to SQLFORM.factory as a record. The keys of the dict should be the same as 
the names of the fields you pass in, and the dict should also include a 
dummy "id" key (its value doesn't matter, as it will be ignored in 
constructing the form if you set showid=False). Something like:

record = dict(id=1, field1=value1, field2=value2, ...) 
form = SQLFORM.factory(Field('field1'), Field('field2'), ..., 
record=record,showid
=False)

I haven't tried it, but that might work.

Anthony

-- 

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