我有一个来自,我想根据数据库中的信息和填充字段自动填充它:
在 db_wizard.py
db.define_table('receiver',
Field('name'), # e.g. Daniel
Field('email'),# e.g. daniel@daniel.com
Field('opening'), # e.g. Dear Daniel
...)
db.define_table('sender',
Field('name'), # e.g. John
Field('email'), # e.g. John@john.com
Field('tel'), # e.g. 111 222 111
...)
db.define_table('letter',
Field('sender', db.sender.id), # e.g. Daniel
Field('receiver', db.receiver.id), # e.g. John
Field('opening'), # should be filled automatically when choosing/changing the value of "receiver"
...)
我使用 plugin_lazy_widget
db.letter.opening.widget = suggest_widget(db.receiver.opening, id_field=db.i2l_receiver_profile.id,
limitby=(0,10), min_length=1, db=db(db.i2l_receiver_profile.user_id==auth.user_id))
但是这个小部件甚至 web2py_autocomplete_widget 总是返回ID
所选记录的!而不是我们真正投入的“开放”,就像上面的例子:它返回1
而不是Dear Daniel