>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.

Yes, that is why I was requesting help from web2py gurus :P

I like the idea for

form.display_errors = False

To disable them. On a global level, however, I think when using custom form,
it should be False by default, and when you are just using crud, it should
be True by default.

When you use {{=form}} errors should display like they are now, however when
you make the call to {{=form.custom.begin}} then you should be required to
use {{=form.custom.errors.fieldname}} to display the errors.

My thinking for {{=form.custom.errors}} is like how {{=form.custom.widget}}
works that it already has the html in it. So having it use a DIV should be
no problem (since that is what it is doing right now, however you have
control over where the DIV will be located in your html)

If all I wanted was the error name,message then I would use {{=form.errors}}
which I am currently using (i loop through the errors, use jQuery to
highlight the row and replace the comment label with the error)

{{
#loop through all errors.
for key, value in form.errors.items():
    #use py2jquery to highlight the rows and replace comment with the error,
and change the color to red!
    manager.add(Script(signup_form_error(key, value)))
}}

The problem with form.display_errors = False, is that the actual error
display is in the INPUT() element, so INPUT will have to know about the
form.display_errors.

How difficult is it to make the INPUT element aware of that?

-Thadeus




On Wed, Oct 7, 2009 at 3:39 PM, mdipierro <mdipie...@cs.depaul.edu> wrote:

>
> 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 <thade...@thadeusb.com> 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 <mdipie...@cs.depaul.edu>
> 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 <thade...@thadeusb.com> 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 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