I have a form with two fields, one field is a selection box of previously
typed values and the other is a text box. User can choose a value from a
selection box or can type a value in text box and submit it in which case I
would like to add a value to a selection box, something like this:
# some code that reads values from db into dictionary_of_typed_values
# create a form
form=SQLFORM.factory(
Field('field1', requires=IS_EMPTY_OR(IS_IN_SET(
dictionary_of_typed_values))),
Field('field2', 'string'))
if form.accepts(request, session):
# insert new value into db
new_value_id = db.table.insert(column1=form.vars.field1, column2
=form.vars.field2)
if form.vars.field1 == None:
# here I would like to add form.vars.field2 to set of
values in field1
return dict(form=form)
The problem is that values are already loaded when program flow reaches
insert statement so inserting value into dictionary will not change what is
in the form.
I would like to have a solution that whenever user types something in
field2 page reloads with the typed value in the selection box. Is there an
elegant way to do it?
Dragan
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.