[Zope3-Users] z3c.form - howto ignore the context for single widgets in an Edit form?

Stephan Richter srichter at cosmos.phy.tufts.edu
Fri Feb 8 11:06:05 EST 2008


On Friday 08 February 2008, Hermann Himmelbauer wrote:
> What's your opinion on this, Stephan?

One important design goal for z3c.form is not to be JS dependent. This is what 
we developed z3c.formjs for. 

Also, remember that a widget is something different in z3c.form. Taking the 
E-mail widget example, we still only have a TextFieldWidget but might have a 
specific EMailValidator registered for this widget.

From this point of view, I think it would be cool, if we could have a 
ConfirmationWidget, which simply displays another widget twice. This 
could then either be a PasswordWidget or TextFieldWidget. The cool part about 
it is that the constructor of the confirmation widget could be smart to take 
the passed in field into account.

So here is how I would like this to look:

class ConfirmationWidget(...)

   widget = None # The widget that we want to display twice.

   ...

def FieldConfirmationWidget(field, request):
    widget = FieldWidget(field, ConfirmationWidget(request))
    widget.widget = zope.component.getMultiAdapter(
        (field, request), IFieldWidget)
    return widget

The challenge is to have unique names for the widget and its confirmation and 
do all the updating correctly. You probably also need a custom validator that 
first compares the two values to be equal and then forwards the validation.

I would love to see this widget in z3c.form. Of course, I am also still 
waiting for the ObjectWidget. :-)

Regards,
Stephan
-- 
Stephan Richter
Web Software Design, Development and Training
Google me. "Zope Stephan Richter"


More information about the Zope3-users mailing list