Annet,

you are using custom widgets but you are not setting their requires
(which is not easy to see, I will give you that).

On Apr 10, 3:53 am, annet <jmverm...@xs4all.nl> wrote:
> I have two function both of which don't execute the way I expect/want
> them to execute.
>
> The first one:
>
> def byplace():
>     form=form_factory(SQLField('plaats',requires=IS_NOT_EMPTY(),\
>     widget=lambda self, value:TAG[''](INPUT
> (_id='byplace',_name='plaats',_class='ac_input',_type='text'))))

 
(_id='byplace',_name='plaats',_class='ac_input',_type='text',requires=self.requires))))

otherwise your INPUT does not know about the field requires.
Note: you can drop the TAG[''](...) around the INPUT, it does not do
anything.

>     if form.accepts(request.vars,session):
>         clubs=db((db.bedrijf.id==db.adres.bedrijf)&
> (db.bedrijf.id==db.bedrijfinschrijving.bedrijf)&\
>         (db.adres.plaats==request.vars.plaats)&
> (db.adres.adressoort=='vestigingsadres')&
>         (db.bedrijfinschrijving.inschrijving=='fitnessclub'))\
>         .select
> (db.bedrijf.id,db.bedrijf.bedrijfsnaam,db.bedrijf.status,\
>         db.adres.straat,orderby=db.bedrijf.status|
> db.bedrijf.bedrijfsnaam)
>     elif form.errors:
>       response.flash='form has errors'
>     else:
>       response.flash='please fill the form'
>       clubs=[]
>     return dict(form=form,clubs=clubs)
>
> Executes alright if I enter a valid plaats (city), however, when the
> auto-complete field is empty  it doesn't display an error message, it
> displays none in the flash. Then, when I enter a plaats which is not
> in the auto-complete drop-box, again the flash displays none. So the
> elif form.errors: is never executed, why not?
>
> Ideally, the auto-comlete drop-box should behave like a standard drop-
> box, i.e. not allow you to enter anything that is not in the drop-box.
> However, the pengoworks auto-complete doesn't work that way.
>
> The second one:
>
> def byzipcode():
>     form=form_factory(SQLField('postcoderegio',requires=[IS_LENGTH
> (2),IS_NOT_EMPTY()],\
>     widget=lambda self, value:TAG[''](INPUT
> (_id='byzipcode',_name='postcoderegio',_class='ac_input',_type='text'))))
>     if form.accepts(request.vars,session):
>         minmax=db(db.postcoderegio.regio==request.vars.postcoderegio).
> \
> select(db.postcoderegio.codemin,db.postcoderegio.codemax)
>         if not len(minmax):
>             response.flash='Please provide a valid postcoderegion'
>             redirect(URL(r=request,f='byzipcode'))
>         else:
>             minimum=int(minmax[0].codemin)
>             maximum=int(minmax[0].codemax)
>             clubs=db((db.bedrijf.id==db.adres.bedrijf)&
> (db.bedrijf.id==db.bedrijfinschrijving.bedrijf)&\
>             (db.adres.postcode_cijferdeel>=minimum)&
> (db.adres.postcode_cijferdeel<=maximum)\
>             &(db.adres.adressoort=='vestigingsadres')&
> (db.bedrijfinschrijving.inschrijving=='fitnessclub'))\
>             .select
> (db.bedrijf.id,db.bedrijf.bedrijfsnaam,db.bedrijf.status,db.adres.straat,
> \
>             db.adres.plaats,orderby=db.bedrijf.status|
> db.bedrijf.bedrijfsnaam)
>     elif form.errors:
>       response.flash='form has errors'
>     else:
>       response.flash='please fill the form'
>       clubs=[]
>     return dict(form=form,clubs=clubs)
>
> Executes alright if I enter a valid postcoderegio (zipcoderegion),
> however, when the auto-complete field is empty or contains a value
> with a length other than 2 it doesn't display an error message, it
> displays please fill the form in the flash.
>
> Then when the value in the auto-complete passes validation, but minmax
> is empty, I expect the message in the flash to be: please provide a
> valid postalcoderegion.
>
> In both functions, when clubs is empty the flash displays none I would
> like to replace that with a more meaning full message, but that would
> introduce another if statement ...
>
> I hope one of you can help me fix this flaws in the flow of execution.
>
> Annet.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to