[Zope3-Users] Cloning interfaces/interface fields - how?

Marius Gedminas mgedmin at b4net.lt
Thu Feb 21 11:34:12 EST 2008


On Wed, Feb 20, 2008 at 01:12:18PM -0500, Stephan Richter wrote:
> On Wednesday 20 February 2008, Hermann Himmelbauer wrote:
> > Yes, I also use z3c.form, but my problem is that the field has the
> > "required" flag set to "True", which is appropriate for an add/edit form
> > but may not be appropriate for a search form.
> >
> > If I change the "required" flag on the field level, e.g. in the update()
> > method, the change is permanent in the interface, which is not appropriate.
> > And changing it on the widget level seems to be very complicated, at least,
> > I found no way to do it.
> 
> Mhh, I think that form fields should support this. Let me look at the code 
> briefly.
> 
> So yes, you need to change it on the widget level; here is what you have to do 
> in your form:
> 
> class MyForm(Form):
> 
>   def updateWidgets(self):
>     super(MyForm, self).updateWidgets()
>     self.widgets['prefix.myfield'].required = False
> 
> Is that too difficult still?

Does that actually work?  I vaguely seem to remember that I tried this
approach once (making the widget not required when the field was
required), but some code from the field itself raised validation errors.

Of course that could've been a bug in Zope 3.2, fixed since.

Marius Gedminas
-- 
Go not unto the Usenet for advice, for you will be told both yea and nay (and
quite a few things that just have nothing at all to do with the question).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mail.zope.org/pipermail/zope3-users/attachments/20080221/4f45689e/attachment.bin


More information about the Zope3-users mailing list