Hi Massimo,

I hope this helps.
Example 1 :
form = SQLFORM.factory(
   Field('fromyr', requires=[IS_INT_IN_RANGE
(1950,2000,error_message='Allowed Years, 1950-2000')],label='*
Enrolled - From Year'),
   Field('toyr', requires=[IS_INT_IN_RANGE
(1950,2000,error_message='Allowed Years,
1950-2000')],label='* ..................... - To Year'))

In Example 1 when form is submitted and there is an error in the range
the form displays the error below the field and the data inputted is
also displayed back.
-----------------------------------------------------------------------
Example 2

      if request.vars.fromyr > request.vars.toyr:
         response.flash=T('To year is less than From Year')
      return dict(form=form)

In Example 2, when the same form is submitted and the range has no
error but encountered an error during the validation in Example 2 a
blank form is displayed together with the error on the upper portion
of the form (like Welcome to Web2py).

What I would like to have is to display the error "To year is less
than From Year" below the field "toyr" even if I validate the 'toyr'
variable like in Example 2.
Thanks again Massimo.


On 1 Okt, 11:48, mdipierro <mdipie...@cs.depaul.edu> wrote:
> sorry. I do not understand. Can you provide an example?
>
> On Sep 30, 10:44 pm, ed <edbi...@rocketmail.com> wrote:
>
> > Sorry Massimo for mixing up my question. What I mean is, when there is
> > an error in validating a variable and response.flash is used it
> > returns an empty form with the error message. If possible I would like
> > to return the error message with a filled form like in validators
> > IS_IN_DB, etc.. Thanks again.
>
> > On 29 Set, 22:06, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > I do not understand. forms have fields with have validators which are
> > > executed automatically.
>
> > > If you have a variable "a" and you want to apply a validator to it you
> > > can
>
> > > (b,error)=IS_INT_IN_RANGE(0,100)(a)
>
> > > where (b, error) == (int(a), None) if a passes or (b, error)==
> > > (a,"error message") otherwise.
>
> > > On Sep 29, 3:51 am, ed <edbi...@rocketmail.com> wrote:
>
> > > > Hi,
> > > > Can i use error_message() in the Controller to validate field data? I
> > > > think i saw somewhere this process. Thanks
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" 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