Because the SQLFORM/FORM API did not provide a hideerror option (until
now) the solution was a trick:
1) move the form.errors into a new local variable errors
2) clear form.errors so that FORM/SQLFORM did not display any

hideerror=True is cleaner because it do not require using a local
variable and because errors stay where they belong in form.errors and
when not displayed.

Massimo

On Jul 27, 9:53 pm, Iceberg <iceb...@21cn.com> wrote:
> Sorry, can someone clarify the difference between the "workaround":
>     errors,form.errors=form.errors,{}
> and the new feature:
>     if form.accepts(....,hideerror=True)
> ?
>
> I think the former is straightforward.
>     form=SQLFORM(....)
>     if form.accepts(....):
>        # all data are perfect
>        do_something()
>     # And I can still deal with the errors, if any
>     errors,form.errors=form.errors,{}
>     return dict(form=form,errors=errors)
>
> Then when and how to use the "hideerror" feature? Is it?
>     form=SQLFORM(....)
>     if form.accepts(....,hideerror=True):
>         do_something()
>         # but wait, are all data ok, or just some error being hidden?
>     return dict(form=form) # And where is my errors?
>
> Regards,
> Iceberg
>
> On Jul 27, 7:50pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > Until this is resolved.... this is how I usually handle the situation.
>
> > form=SQLFORM(....)
> > if form.accepts(....)
> >     errors,form.errors=form.errors,{}
> > return dict(form=form,errors=form)
>
> > Unless you do this the philosophy is that widgets handle their own
> > errors and they can be customized by overriding .xml().
>
> > On Jul 27, 6:00 am, Thadeus Burgess <thade...@thadeusb.com> wrote:
> > > This has been a problem for quite some time, I just did not get around
> > > to complaining about it again until now =)
>
> > > If I am to use a custom form (which I almost always do). Then I can't
> > > have my form elements going off and rendering their own errors now can
> > > I? Not very enterprisey of SQLFORM to just assume I want to always
> > > display errors automatically.
>
> > > --
> > > Thadeus
>
> > > On Tue, Jul 27, 2010 at 5:04 AM, mdipierro <mdipie...@cs.depaul.edu> 
> > > wrote:
> > > > It is the INPUT widget that upon serialization displays the errors. I
> > > > can see it may be a problem with custom widgets.
>
> > ......
>
> > > >> > On Jul 27, 2:29 am, Thadeus Burgess <thade...@thadeusb.com> wrote:
> > > >> >> I don't get it....
>
> > > >> >> SQLFORM.factory(Field.....,hideerror=True).
>
> > > >> >> It doesn't do what its supposed to.
>
> > > >> >> How can I make sure that none of my widgets render errors alongside
> > > >> >> their own INPUT elements without rewriting everything in sqlhtml?
>
> > > >> >> --
> > > >> >> Thadeus

Reply via email to