Reputation: 973
With two tables:
db.define_table('content',
# Here I want to store the id of the chosen layout_type
Field('layout_type_id', db.layout_type),
# Here the plain name - might not be necessary
Field('layout_type_name', 'list:string')
)
db.define_table('layout_type',
Field('layout_type_name', 'string')
)
db.content.layout_type_name.requires = IS_IN_DB(db, 'layout_type.id', '%(layout_type_name)s')
I create a form
form = crud.update(db.mytable, id)
where I want a Dropdown menu to choose a layout_type_name
from - which is working - and store the id
of the chosen entry.
How is it possible to store the id
of the chosen layout_type_name
in content.layout_type_id
?
Also, if I choose one entry in the dropdown mentioned above - the (text)value is not stored when the form is successfully submitted.
Upvotes: 0
Views: 83
Reputation: 973
These changes made this problem work:
db.define_table('content',
Field('content_type_id', db.content_type)
)
db.define_table('layout_type',
Field('layout_type_name', 'string'),
format='%(layout_type_name)s'
)
This post about record representation is exactly what I was initially looking for.
Upvotes: 1