GET forms without _formname

9 views
Skip to first unread message

virhilo

unread,
Apr 12, 2009, 6:03:29 PM4/12/09
to web2py Web Framework
Hello:)
I want to send a form using get method, so i make form like this:

form=FORM('Package name: ',
INPUT(_name='name', requires=IS_LENGTH(25), value=''),
'Arch: ',
SELECT(OPTION('Wszystkie', _value='all'),
OPTION('i686', _value='32'),
OPTION('x86_64', _value='64'),
requires=IS_IN_SET(['all', '64', '32']),
value='all',
_name='arch'),
INPUT(_type='submit', _value='Search...'),
_method='get',
_action=None)
form.accepts(request.vars)

Everythink working fine, but web2py adding _formname to
request.get_vars, it make urls less reradable.

Turicas from #web2py irc channel helps me to find solution, when
formname='' was added to form.accepts args (so it's now look like
that: form.accepts(request.vars, formname='') ) but then the form
validation don't working,

so another solution is setting formname to None ( form.accepts
(request.vars, formname=None) ), but then the value fields from SELECT
and INPUT are not parsed, form return error 'Value not allowed'

The web2py default's is to send formname as a hidden field _formname.
i think it is unnecessary. The only modification here is that if user
submit a form without fill any field, form won't show errors.

Version 1.60.5 (2009-04-12 11:21:07)

virhilo

unread,
Apr 20, 2009, 7:33:46 AM4/20/09
to web2py Web Framework
That issue is still existing :(
Message has been deleted

mdipierro

unread,
Apr 20, 2009, 10:16:02 AM4/20/09
to web2py Web Framework
I believe this is working but I think you want something slightly
different:

def test():
form=FORM('Package name: ',
INPUT(_name='name', requires=IS_LENGTH(25), value=''),
'Arch: ',
SELECT(OPTION('Wszystkie', _value='all'),
OPTION('i686', _value='32'),
OPTION('x86_64', _value='64'),
requires=IS_IN_SET(['all', '64', '32']),
value='all',
_name='arch'),
INPUT(_type='submit', _value='Search...'),
_method='get',
_action=None)
if request.vars and form.accepts(request.vars,formname=None):
session.flash="searching..."
redirect('somewhere')
return dict(form=form)

virhilo

unread,
Apr 20, 2009, 12:16:13 PM4/20/09
to web2py Web Framework
No i don't want redirections-i want to stay on the same site:) Only
don't want to have _formname in url.
formname=None cause the INPUT and SELECT '_value' is not parsed
formname='' disable validation :(
or maybe I doing something wrong?

mdipierro

unread,
Apr 20, 2009, 12:29:14 PM4/20/09
to web2py Web Framework
Then this should do it

if request.vars and form.accepts(request.vars,formname=None):
response.flash="done"

Massimo

virhilo

unread,
Apr 20, 2009, 12:40:17 PM4/20/09
to web2py Web Framework
Thanks a lot-it's working:)
I can have only:
request.vars and form.accepts(request.vars, formname=None)
line(without 'if') if i don't want to display any information-yes?:)

mdipierro

unread,
Apr 20, 2009, 12:55:42 PM4/20/09
to web2py Web Framework
correct

Álvaro Justen [Turicas]

unread,
Apr 20, 2009, 2:00:36 PM4/20/09
to web...@googlegroups.com
On Mon, Apr 20, 2009 at 1:40 PM, virhilo <vir...@gmail.com> wrote:
>
> Thanks a lot-it's working:)
> I can have only:
> request.vars and form.accepts(request.vars, formname=None)
> line(without 'if') if i don't want to display any information-yes?:)
>
> On 20 Kwi, 18:29, mdipierro <mdipie...@cs.depaul.edu> wrote:
>> Then this should do it
>>
>>     if request.vars and form.accepts(request.vars,formname=None):
>>          response.flash="done"

It was added in last releases? I remember that I tried it and didn't work.

--
Álvaro Justen
Peta5 - Telecomunicações e Software Livre
21 3021-6001 / 9898-0141
http://www.peta5.com.br/

mdipierro

unread,
Apr 20, 2009, 2:36:21 PM4/20/09
to web2py Web Framework
Has been there is a while. It is possible it was broken in the pre
1.53 version.

On Apr 20, 1:00 pm, Álvaro Justen [Turicas] <alvarojus...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages