Jim, Thanks. I had already tried that, and it doesn't work for me. I wrote a little controller to test it:
@auth.requires_login() def test_vars(): form = FORM( FIELDSET('Subject: ', INPUT(_name='subject')), FIELDSET('Other subject: ', INPUT(_name='otherSubject')), 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(request, keepvalues=True): response.flash = 'oky' elif form.errors: response.flash = 'form has errors' else: form.vars.subject = 'my subject' form.element(_name='otherSubject')['_value'] = 'other subject' return dict(form=form) I have no view, so I get the default. The form I see displayed has a blank for the field 'subject', and the field 'otherSubject' is filled with 'other subject'. Now, that said, I could *easily* believe I'm screwing something else up. If that example works on your system, then there's something else I'm doing wrong. Thoughts? On Wednesday, October 31, 2012 5:59:26 PM UTC-6, Jim S wrote: > > form.vars.fieldname = 'fieldvalue' > > > -Jim > > On Wednesday, October 31, 2012 6:13:20 PM UTC-5, MichaelF wrote: >> >> 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. >> > --