Karl Guertin wrote:
> On 1/17/06, Jorge Godoy <[EMAIL PROTECTED]> wrote:
> > > Eh, I need it for a project. I'll do it right now unless you're mostly
> > > done.
>
> This is in r530. I used css_classes because although it isn't quite as
> accurate, there's no chance of someone thinking it's some sort of
> multiple inheritance tracking or something.
While working on ticket #125 I touched also the required field problem,
I think all these things should be managed by the form (label display,
required display, error display) not by the field itself.
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).
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.
>>> test = validators.Int(not_empty = True)
>>> test.not_empty
True
>>> test = validators.Int()
>>> test.not_empty
False
>>>
Then for example in the TableForm:
<td py:if="widget.validator.not_empty"
class="required_field">${widget.insert(getattr(self.widget_value,
widget.name, None), input_values, widget_error.get(widget.name,
None))}</td>
<td py:if="not
widget.validator.not_empty">${widget.insert(getattr(self.widget_value,
widget.name, None), input_values, widget_error.get(widget.name,
None))}</td>
(Note: Kid needs if/else :-()
In this way you just specify in the validator that you want this field
to be not empty and it's displayed in the right way by the form, with
the css_classes solution you need to also specify that special class.
I would expect it to work only by defining not_empty on my validator,
it's DRY.
What do you think?
Ciao
Michele