I'm certain this has been asked a bunch of times. I've spent the last
hour looking for it but can't find it anywhere. Sorry.

The question is how to set the default value of a reference field
based on a query of the referenced table.

db.define_table('car_makers',Field('name',unique=True))
db.define_table('car',
  Field('make',db.car_makers,IS_IN_DB(db,'car_makers.name','%(name)
s')),
  Field('model'))

I want to set db.car.make.default=db(db.car_makers.name=='Ford').select
(db.car_makers.id)[0]
so that when I do an SQLFORM, the drop down list of db.car.make will
pre-select "Ford".

This isn't working for me. What am I doing wrong?

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.

Reply via email to