Hello again,

I withdraw my question as I managed to get the obvious working:
form.vars.cpaid = 6   # or whatever id is required

I failed to get this working earlier, so I mistakenly assumed that the
solution was more complex.  I must have made some dumb mistake that
disabled proper operation.

Sorry for the wasted post...

On Jun 10, 8:05 pm, tomt <tom_tren...@yahoo.com> wrote:
> Hi,
>
> I've written a controller to add a record using sqlform, and I want to
> prepopulate several of the fields.  I've had some success using
> form.var.field = x, but I haven't been able to prepopulate the one
> field that uses a dropdown list.
>
> In the controller I listed below, I have success on the 'description'
> field, but not the 'cpaid' field.
>
> Any suggestions?
>
> Model:
> db.define_table('cpa',
>     Field('cpa','string'),
> ...
>
> db.define_table('task',
>     Field('cpaid'),
>     Field('cpaord'),
>     Field('cpa','string'),
>     Field('description','string'),
> ...
>
> db.task.cpaid.requires = IS_IN_DB(db,'cpa.id','cpa.cpa')
>
> Controller.
> def insert_task_cpa():
>     form = SQLFORM(db.task)
>     form.vars.description = 'Test Description'
>     form.vars.cpaid = IS_IN_DB(db,db.cpa.id, '6')
>     if form.accepts(request.vars,session):
>         response.flash='Task added'
>         redirect(URL('task_list_bycpa', args=cpa_id))
>     return dict(form=form)

Reply via email to