Closed thet closed 2 years ago
Determining the default value might need the context (we do have that in our project) and AFAIK ignoreContext
is for determining widget values
description=_('A flag, when set, forces the widget not to look at '
'the context for a value.'),
not sure we should take both under the same hat
@thet What kind of form are you using? Is it an AddForm or EditForm or something else?
@icemac it's an edit form from https://github.com/plone/plone.app.registry/blob/master/plone/app/registry/browser/controlpanel.py#L19
@agroszer if I understand correctly from the description, a fix like shown above would be appropriate?
@thet If it es an edit form each field should be bindable to the context. How do you save the values if binding does not work when loading them?
@thet re "if I understand correctly from the description, a fix like shown above would be appropriate?"
On the contrary, I'd rather do not mix the two.
Also, field.bind(None)
should work without an exception, we use it to clone a field.
Stale issue, cleaning up.
I got an error with
field.bind(self.context)
, where context was nothing the field could be bound to. the context was a plone.registryRecordProxy
, which was lacking a__parent__
attribute (now fixed in a branch and submitted as PR). For reference, an excerpt of the traceback is copied further down.But however, it appears to me wrong, that for forms where
ignoreContext
is set toTrue
the field tries to bind itself to a context in this line: https://github.com/zopefoundation/z3c.form/blob/f1d702e948e709db8ba645e4bd6d741e49a48da8/src/z3c/form/widget.py#L112I tried that to chang to:
And the error was gone.
Not sure, if it's intentional that the field is bound to the context, even for
ignoreContext
forms.../cc @agroszer @icemac