Currently, the TableForm/ListForm widgets display error messages beside
the widgets they apply to, but don't actually modify the widget itself.

We really want to have error messages listed at the top of the form and
red boxes around the widgets that have errors related to them.

To list the columns with errors on them, we end up looping through
cherrypy.request.validations_errors like this:
<div
py:for="i, error in getattr(cherrypy.request, 'validation_errors',
{}).iteritems()" class="error">${i}: ${error}</div>

I realize that if I have compound widgets error won't just be a string,
but I don't have that case just yet.  If I run into that case, I'll
probably create a dict similar to validation_errors with the proper
column names and iterate over that instead of validation_errors.

Now, to put red boxes around the form fields, you usually use css, but
how do I add a css class to a widget when I don't want to do any
processing in the template and my display function is of the form
summary.display(value_for(summary), **options_for(summary))?

It seems logical to do something to make options_for tell the widget
about my new class.  I wrote something just like that, I called it
update_options.  It looks something like this:

def update_options(self, d, item, name, key, value):
    path = widgets.path_from_item(item)
    if len(path) is 0:
        return None
    else:
        options = d['tg_options']
        options = options.setdefault(name, {})
        for p in path:
            options = options.setdefault(p[0], {})
        options[key] = value

I've had to modify it once already, as a fix to the changes created by
repeating widgets.

Is this a good way to do what I want to do?  If it is, can I get an
official version of update_options, so that I don't have to keep
updating mine every time something related to widgets and options
changes?

Jason

Attachment: signature.asc
Description: PGP signature

Reply via email to