Thank you.  That works.  Now I'm keeping the form history and letting the 
user select any previous set of values.  I have found that this works for 
me:

record = oldvals    # oldvals are from a previous form.vars
record['id'] = ''

form=SQLFORM.factory(
  Field(...),
  Field(...),
  ...,
  record=record,
  showid=False
)



On Monday, February 11, 2013 1:38:01 PM UTC-5, Massimo Di Pierro wrote:
>
> form=SQLFORM.factory(
>   Field(...),
>   Field(...)).process(keepvalues=True)
>
> On Monday, 11 February 2013 10:56:54 UTC-6, Tom Hines wrote:
>>
>> Hello.  I want to use SQLFORM.factory() and pre-populate a form with 
>> values from the last form use.  Kind of like an update form.  It works some 
>> of the time, but I'm getting a lot of KeyError: 'id' exceptions.  There 
>> is no 'id' field.  Using web2py version 2.3.2.  Thanks for any help.
>>
>> Example:
>>
>> record = oldvals    # oldvals are the old form.vars
>>
>>
>> form=SQLFORM.factory(
>>   Field(...),
>>   Field(...),
>>   ...,
>>   record=record)
>>
>>
>> Traceback (most recent call last):
>>   File "...\web2py\gluon\restricted.py", line 212, in restricted
>>     exec ccode in environment
>>   File "..." 
>> <http://localhost:8000/admin/default/edit/intersection/controllers/query.py>,
>>  line 2754, in <module>
>>   File "...\web2py\gluon\globals.py", line 193, in <lambda>
>>     self._caller = lambda f: f()
>>   File "...\web2py\gluon\tools.py", line 2929, in f
>>     return action(*a, **b)
>>   File "..." 
>> <http://localhost:8000/admin/default/edit/intersection/controllers/query.py>,
>>  line 526, in ...
>>     record=record
>>   File "...\web2py\gluon\sqlhtml.py", line 1546, in factory
>>     **attributes)
>>   File "...\web2py\gluon\sqlhtml.py", line 1018, in __init__
>>     self.record_id = str(record[field.name])
>> KeyError: 'id'
>>
>>

-- 

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