Feed on
Posts
Comments

For a Zope FormLib based form I wanted a ‘Cancel’ button. I tried some googling but couldn’t find any info on it. Here it is, it isn’t so hard:

First do some imports:

from plone.app.form.validators import null_validator
from Products.statusmessages.interfaces import IStatusMessage

The cancel function:

@form.action(“Cancel”, validator=null_validator)
def action_cancel(self, action, data):
….context = aq_inner(self.context)

….IStatusMessage(self.request).addStatusMessage(_(‘Cancelled’), type=’info’)

….self.request.response.redirect(\
….context.absolute_url()+’/@@mypage’)

nb. wordpress messes with the indentation, hence the dots. time for a code mark-up plugin….

Trackback URI | Comments RSS

Leave a Reply