mdipierro wrote:
> because keyword appears both in get and in post. You can try:
>
> form=SQLFORM.factory(
> Field('keyword',
> default=keyword,
> )
> _method="GET")
>
> or
> form=SQLFORM.factory(
> Field('keyword',
> default=request.vars.keyword,
> ))
> if form.accepts(request.post_vars, session):
> response.flash = 'Submitted'
>
> really depends on what you need.
>
Thanks for your help. I was able to come up with a solution once I
understood the get and post vars.
The logic I was after is:
* On the page first displaying, if a keyword is provided in the url
parameters then use it as the default.
* On refreshing the page after a submit, use whatever value was
submitted.
Heres the code:
def search():
keyword = ''
if 'keyword' in request.post_vars:
keyword = request.post_vars.keyword
elif 'keyword' in request.get_vars:
keyword = request.get_vars.keyword
form=SQLFORM.factory(
Field('keyword',
default=keyword,
),
)
if form.accepts(request.vars, session):
response.flash = 'Submitted'
return dict(form=form)