I have these tables,
db.define_table('languages',
Field('full', 'string', length=30, notnull=True,
required=True),
Field('short', 'string', length=10 , notnull=True,
required=True),
format='%(full)s - %(short)s')
db.define_table('words',
Field('word', 'string', length=128, notnull=True,
required=True),
Field('lang', db.languages, notnull=True))
index is like this
def index():
form = SQLFORM.factory(db.words)
return dict(form=form)
and in view:
(My aim is to replace select box with my own select box which removes one
option from select box)
(But use case is really, replacing default select box with a select box that
have <OPTGROUPS >)
defaultlang = db(db.languages.full =='All Languages').select().first()
lst = db(db.languages.id>0).select().sort(lambda a: a.full).exclude(lambda
a: a.id != defaultlang.id)
options = [OPTION(row['full'] + ' - ' + row['short'], _value=row['id']) for
row in lst]
Now I tried following, individually of course:
form.custom.inpval['lang']= SELECT(*options)
form.custom.dspval['lang']= SELECT(*options)
form.custom.widget['lang']= SELECT(*options)
If I display form {{=form}} select box is still old one.
If I try {{form.custom}} then corresponding (ie., inpval.lang, dspval.lang,
widget.lang) displays new select box.
But {{=form}} still displays old select box.
So what's the use of custom.inpval, dspval and widget?
And, How to solve this particular problem? (ie., customizing an element
(here change an select box with a select box which have optgroups))