[Product-Developers] RichTextWidget wysiwyg editor not displaying actual value after action

David Glick davidglick at groundwire.org
Thu Apr 5 05:43:38 UTC 2012


On 3/19/12 12:11 AM, Régis Rouet wrote:
> Hi,
>
> I try to have a reset button on a customized dexterity.EditForm
> to set a RichText field with a computed value while staying on the edit
> form.
>
> For example :
>
> class EditForm(dexterity.EditForm):
>      grok.context(IScreening)
>      z3cform.extends(dexterity.EditForm)
>
>      def updateWidgets(self):
>          super(EditForm, self).updateWidgets()
>
>      @button.buttonAndHandler(u'Reset', name='reset')
>      def handle_reset(self, action):
>          data, errors = self.extractData()
>          data['user_text'] = u'reset' + '   ' + datetime.now().isoformat()
>          self.applyChanges(data)
>          self.updateWidgets()
>
> The problem is that the wysiwyg editor keep displaying the old value.
> If I click on the "edit without wysiwyg editor" link, I then get the actual
> value.
>
> I'm new to z3c.form and not sure to have a correct code.
>
> Any opinion ?
>
> I use Plone 4.1.4 and dexterity 1.2.
>
It's not working because RichText fields need to store a 
plone.app.textfield.value.RichTextValue object, not a unicode string.

But if you don't need to actually store the new value on the object, you 
can do it this way (since widgets use the value in the request in 
preference to obtaining a value from the form's content item):

     @button.buttonAndHandler(u'Reset', name='reset')
     def handle_reset(self, action):
         data, errors = self.extractData()
         self.request.set('form.widgets.body', u'reset' + '   ' + 
datetime.now().isoformat())
         self.updateWidgets()

David


----------		
David Glick
 Web Developer
 davidglick at groundwire.org
 206.286.1235x32

The Engagement Party 2012. So much more fun than the wedding reception.

http://www.npoengagementparty.com




More information about the Product-Developers mailing list