Hi Manuele,

1) 'value' ultimately depends on a static dictionary (d)
2) web2py executes models/controllers on every request

then you would have to store the dictionary in the session (or in the
DB), as shown in
http://web2py.com/book/default/chapter/03#Let%27s-Count



On May 11, 4:22 am, Manuele Pesenti <[email protected]> wrote:
> Hi,
> Reading past posts about this topic and the book I didn't realize how to
> solve it. Imagine to have the subsequent controller called "bar"
>
> d = dict(
>          a=[1,2,3],
>          b=[4,5,6])
> def foo(k):
>      if k in d:
>          return d[k]
>      else:
>          l = []
>          for i in d.values():
>              l += i
>          return l
>
> def bar():
>      form = SQLFORM.factory(
>          Field('username', requires=IS_NOT_EMPTY()),
>          Field('key', requires=IS_IN_SET(d.keys())),
>          Field('value', requires=IS_IN_SET(foo(request.vars.key))))
>      if form.accepts(request.vars, session):
>          pass # or take some action
>      return dict(form=form)
>
> What's the Ajax I have to add to my view in order to modify on the fly
> the drop down list of the "value" field?
>
> Thank you very mutch in advance
> Cheers
>         Manuele

Reply via email to