I have a 'regular' form (i.e., FORM, not SQLFORM). I want to prepopulate 
some of the fields, but I don't know the values to use for them when I 
first create the form. What's the best practice for populating field 
'subject'? Is it using the 'element' function? For example:

form = FORM(
    FIELDSET('Subject: ', INPUT(_name='subject')),
    FIELDSET('Recipients: ', INPUT(_name='recips', )),
    FIELDSET('Message: ', TEXTAREA(_name='message')),
    INPUT(_type='submit', _value='send', _name='sendBtn'),
    INPUT(_type='submit', _value='cancel', _name='cancelBtn'))
if form.accepts(...):
   ...
elif form.errors:
   ...
else:
   someCalculatedValue = some_database_call()
   form.element(_name='subject')['_value'] = someCalculatedValue

Thanks.

-- 



Reply via email to