Am Donnerstag, 21. Februar 2008 17:34 schrieb Marius Gedminas:
> 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.

Heh, this was also my first reaction on this as I also received such an error 
some time ago but could not really remember if it was my fault or not, but as 
you mention it, too, there seems to be some problem. ;-)

Regards,
Hermann

-- 
[EMAIL PROTECTED]
GPG key ID: 299893C7 (on keyservers)
FP: 0124 2584 8809 EF2A DBF9  4902 64B4 D16B 2998 93C7
_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to