[Zope3-Users] providing IInputWidget using zope:view?

Garrett Smith garrett at mojave-corp.com
Thu Jun 2 17:29:36 EDT 2005


Tale a look at:

  src/zope/app/form/browser/configure.zcml

This is where the Zope widgets are registered for various field types.
E.g. here's a registration that provides IInputWidget for ITextLine
fields via the TextWidget class.

  <view
      type="zope.publisher.interfaces.browser.IBrowserRequest"
      for="zope.schema.interfaces.ITextLine"
      provides="zope.app.form.interfaces.IInputWidget"
      factory=".TextWidget"
      permission="zope.Public"
      />

 -- Garrett

Dylan Reinhardt wrote:
> So I've got some custom fields and custom widgets.  Everything works
> fine if I use the widget subdirective to editform to ensure that the
> correct widget is paired with each field.
> 
> For how many times I'm going to re-use certain field/widget pairs, I
> would like to associate a custom input widget with a specific field
> interface so that *any* time that field is rendered in an editform,
> the proper widget is used.
> 
> Obviously, that's not a new idea... there's an example in Stephan
> Richter's book.  He suggests something like this:
> 
> ----
> <zope:view
>      type="zope.publisher.interfaces.browser.IBrowserRequest"
>      for=".interfaces.IMyField"
>      provides="zope.app.form.interfaces.IInputWidget"
>      factory=".widgets.MyWidget"
>      permission="zope.Public"
>      />
> ----
> 
> So far, I haven't managed to get this to work.  I've tried a number of
> things, such as adding a name, using class instead of factory, using
> browser:view instead of zope:view.  All with no joy.    It doesn't
> give any errors, but it doesn't provide the intended widget either.
> 
> Can anyone spare a quick example or suggest what I'm not doing
> correctly? 
> 
> Many thanks in advance,
> 
> Dylan
> _______________________________________________
> Zope3-users mailing list
> Zope3-users at zope.org
> http://mail.zope.org/mailman/listinfo/zope3-users



More information about the Zope3-users mailing list