Hi Thadeus,

we just need to talk about this more and get more opinions. I can be
convinced. The code you proposed does not show errors by default any
more.
That is a break of backward compatibility.

You also assume that people who do not want to display the default
errors would use one DIV for each error. Perhaps or perhaps not.

How about a new flag like

    form.display_errors=True or False

and if false you can do {{=DIV(form.error.fieldname,_class='error')}}
in code?

Massimo

On Oct 7, 2:54 pm, Thadeus Burgess <[email protected]> wrote:
> But I do want to display errors... just not where web2py insists they
> display.
>
> And I think there is a solution here that will satisfy everybody, that kind
> of thinking is NOT good for the growth web2py!!!
>
> I am just not familiar enough with the base code, but I suppose I will get
> familiar with it to find this solution that will satisfy everybody.
>
> -Thadeus
>
> On Wed, Oct 7, 2009 at 1:47 PM, mdipierro <[email protected]> wrote:
>
> > I doubt there is a solution here that would satisfly everybody.
>
> > If you do now want to display errors automatically do
>
> >    form.errors.clear()
>
> > Massimo
>
> > On Oct 7, 12:13 pm, Thadeus Burgess <[email protected]> wrote:
> > > I am attempting to patch web2py to allow support for custom errors in
> > custom
> > > forms, so that the widgets to auto magically render the errors when using
> > > custom form.
>
> > > Desired functionality should behave such as
> > "{{=form.custom.errors.field}}"
> > > and would display "<div id='field__error' class='error'>must contain a
> > > value!</div>"
>
> > > The below patch provides this functionality, however, when using regular
> > > form, it will not render the error div.
>
> > > Perhaps there is a less intrusive method? Something that will still work
> > > with just calling {{=form}}
>
> > > I would think that the new errors DIV would need to be appended to the
> > > components of the SQLFORM?
>
> > > Could someone with more knowledge of the web2py innerworkings help me
> > with
> > > this?
>
> > > Index: gluon/html.py
> > > ===================================================================
> > > --- gluon/html.py    (revision 1258)
> > > +++ gluon/html.py    (working copy)
> > > @@ -1092,8 +1092,8 @@
> > >      def xml(self):
> > >          name = self.attributes.get('_name', None)
> > >          if name and hasattr(self, 'errors') and self.errors.get(name,
> > > None):
> > > -            return DIV.xml(self) + DIV(self.errors[name],
> > _class='error',
> > > -                errors=None, _id='%s__error' % name).xml()
> > > +            return DIV.xml(self) #+ DIV(self.errors[name],
> > _class='error',
> > > +              #  errors=None, _id='%s__error' % name).xml()
> > >          else:
> > >              return DIV.xml(self)
>
> > > Index: gluon/sqlhtml.py
> > > ===================================================================
> > > --- gluon/sqlhtml.py    (revision 1258)
> > > +++ gluon/sqlhtml.py    (working copy)
> > > @@ -756,6 +756,10 @@
> > >                      del self.errors[key]
> > >              if not self.errors:
> > >                  ret = True
> > > +
> > > +        self.custom.errors = Storage()
> > > +        for key, value in self.errors.items():
> > > +                self.custom.errors[key] = DIV(value, _class='error',
> > > errors=None, _id='%s__error' % key).xml()
>
> > >          requested_delete = \
> > >              request_vars.get(self.FIELDNAME_REQUEST_DELETE, False)
>
> > > -Thadeus
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to