[Zope] z3c.form - custom terms for a radio widget

Dan Fairs dan.fairs at gmail.com
Fri May 8 07:22:52 EDT 2009


Hi,

I'm trying to override the default terms for a radio widget on a Bool  
field. My schema and form are as follows:

class IBookingForm(Interface):
     agree_tc = Bool(
         title=u"Booking Terms and Conditions",
     )

class BookingForm(AddForm):
     fields = field.Fields(IBookingForm)

So, pretty straightforward. This renders out with 'yes' and 'no' as  
the values. I'd like this to display as 'I agree' and 'I don't agree'.

The docs say that you should provide an alternate set of terms to  
change the labels, so I have this class:

class TandCBoolTerms(term.BoolTerms):
   trueLabel = u"I Agree"
   falseLabel = u"I Don't Agree"

However, I'm now slightly at a loss as to how to register this terms  
class for that single field on the form - the docs don't mention that!  
Looking at the code, I can see the multi-adapter lookup in  
z3c.form.widget.SelectWidget.updateTerms(), which looks like what I  
want. Is there some kind of discriminator I can use (like the  
StaticWidgetAttribute class) to help with this registration?

Thanks,
Dan
--
Dan Fairs <dan.fairs at gmail.com> | http://www.fezconsulting.com/



More information about the Zope mailing list