On 1/18/06, Michele Cella <[EMAIL PROTECTED]> wrote:
> As I said in another discussion, the css_classes attribute you added
> makes sense only for simple widget (in fact you added it to only a tag
> of the form or the grid, and the others?) moreover it works just like
> the attrs widget (ok, with the latter you have to provide the original
> class but it works in the same manner, it's there for this reason).

I added the tag to the outermost class on the form. Classes inside
that element can either be accessed via css selectors or, in the case
of forms/grids, putting a css_classes on the elements you're passing
in.

As to the attrs widget, I had tried it and it didn't seem to be
working. It works just fine if there isn't an already existing attr
with the same attribute name.


> The right solution IMHO is relying on the not_empty attribute you pass
> to the widget validator, when a form insert a field it should check if
> the widget validator has not_empty set and in this case add a
> "required_field" class name to the field cell.

AFAIK (and I've looked through most of the formencode codebase) there
is no way to definitively tell from a validator whether a field is
required or not without actually trying the to_python method with an
empty string. The not_empty attribute doesn't cover compound or custom
widgets. For example, I can use:

validator = V.Any(V.Int,V.Empty)

To make the validator field optional and not_empty won't appear on any
of the validators.


> I would expect it to work only by defining not_empty on my validator,
> it's DRY.

I'm not so much a fan of DRY. It seems DRY tends to be synonymous with
'magic happens'.

Reply via email to