[Grok-dev] Re: how to hide a field in setUpWidgets
Ivo van der Wijk
vladdrac at gmail.com
Thu Jul 10 11:18:28 EDT 2008
2008/7/10 Ivo van der Wijk <vladdrac at gmail.com>:
> In my add/edit forms I want to conditionally hide a field created
> through grok.AutoFields and, if possible, provide a (default) value.
> Removing the field entirely is also an option.
> Any hints on how to do this? There's a hidden() method on most widgets
> that render the field hidden, but I don't know how I can get the
> formrendering machinery to invoke that.
Answering my own question: With help from timte on #grok I've found
the following solution:
Conditionally set self.form_fields using grok.Autofields combined with
def __init__(self, context, request):
self.form_fields = grok.AutoFields(..).omit('special_field')
self.form_fields = grok.AutoFields(..)
I'm still open to alternative suggestions (i.e. hiding the widget) but
this will do the trick for now.
Drs. I.R. van der Wijk / m3r Consultancy B.V.
Linux/Python/Zope/Plone and Open Source solutions
PO-box 51091, 1007 EB Amsterdam, The Netherlands
Email: ivo <at> m3r.nl Web: http://m3r.eu/
More information about the Grok-dev