If the controller function is expecting a form field value, it should
be retrieved with request.vars.<name>, where <name> is the field name
in the form. You can also retrieve the form fields values with
form.vars.<name> after .process() (if the form passes validation)
or .accepts()

Anyway, I don't know how are you sending the arguments, if by a web2py
form or within an ajax request. If the case is the second, you should
make sure the parameters in the url are correct. As the server
receives the requested url, each request argument is separated by a
"/" for GET method.

On 17 feb, 07:33, Annet <[email protected]> wrote:
> Hi Alan,
>
> Thanks for your replies. They pointed me in the right direction to
> solve the multiselect problem. I am left with one small problem.
>
> The form that contains the multiselect also contains an autocomplete
> function:
>
> def index():
>     ....
>     form=SQLFORM.factory(
>         Field('word',label='Trefwoord',length=128,requires=\
>
> IS_IN_DB(db(db.NetworkKeyword.networkID==session.hubnetworkID),db.NetworkKeyword.word,'%
> (word)s',\
>         zero='Select a value')),
>
> Field('locality_args',label='Plaats',length=64,requires=IS_NOT_EMPTY()),separator=False)
>     ....
>     return dict(form=form,rows=rows)
>
> def locality_args_autocomplete():
>
> rows=db((db.NodeKeyword.word==request.args(0))&(db.NodeKeyword.nodeID==db.Address.nodeID)&
> \
>     (db.Address.locality.like(request.vars.term+'%')))\
>     
> .select(db.Address.locality,distinct=True,orderby=db.Address.locality).as_list()
>     result=[r['locality']for r in rows]
>     return response.json(result)
>
> .... and in the view:
>
> <script type="text/javascript">
> $(function() {
>   $("#no_table_locality_args").autocomplete({
>     source: "{{=URL('hubaddressbook',
> 'locality_args_autocomplete',args='javascript:$
> (select#no_table_word).val();')}}",
>     minLength: 2
>   });});
>
> </script>
>
> ... which gives me an invalid path (args) error.
>
> When I set args='software engineer' in the source and
> db.NodeKeyword.word=='software engineer' in the
> locality_args_autocomplete() function, the code works, however, with
> form.vars.word in the view and request.args(0) in the function it
> doesn't. Do you know with what code I have to replace 'software
> engineer' to get both functions to work.
>
> Kind regards,
>
> Annet.

Reply via email to