Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set values of a Plone autoform in update methode with ignoreContext = True

Tags:

zope

plone

I'm trying to make a form where I'm storing values outside of the context. Storing is done and working well but now I would like the update method to fill the form on rendering process. So I'm overriding update method of the Form class that way:

def update(self):
    super(ConfigurationForm,self).update()
    form = self.request.form
    if not form:
        #We are on a rendering process
        provider = self.getProvider()
        settings = provider.get()
        #TODO: update widget values !?

settings is a dict where keys are equals to Interface fields's names.

So I have tried many ways to update widgets values:

  • Using dataconverter (too much complex and don't know if this is the only way
  • Updating the self.request.form dict and call again the update method
  • playing with field objects

What is the good way to achieve this ? (supporting all kind of field ?)

like image 679
toutpt Avatar asked Oct 23 '25 14:10

toutpt


1 Answers

Don't do ignoreContext. Override getContent() to return a dict instead. The dict will be used as a pseudo context.

like image 86
optilude Avatar answered Oct 27 '25 03:10

optilude



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!