Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from zope import schema
- from five import grok
- from plone.directives import form
- from Products.CMFPlone.interfaces import IPloneSiteRoot
- from plone.supermodel.model import Fieldset
- from plone.supermodel.interfaces import FIELDSETS_KEY
- class IMySchema(form.Schema):
- field_one = schema.TextLine(title=u"Field one")
- field_two = schema.TextLine(title=u"Field two")
- field_three = schema.TextLine(title=u"Field three")
- IMySchema.setTaggedValue(FIELDSETS_KEY,
- [
- # Fieldset('fieldset-one', fields=['field_one'],
- # label=u"Fieldset 1"),
- Fieldset('fieldset-two', fields=['field_two', 'field_three'],
- label=u"Fieldset 2")
- ])
- class MyForm(form.SchemaForm):
- ignoreContext = False
- schema = IMySchema
- grok.name('test-form')
- grok.require('zope.Public')
- grok.context(IPloneSiteRoot)
- def getContent(self):
- return {'field_one': u'A',
- 'field_two': u'B',
- 'field_three': u'C'
- }
- def updateWidgets(self):
- super(MyForm, self).updateWidgets()
- # if there is no default fieldset, self.widgets._data is empty
- # if there is default fieldset, self.widgets._data
- # contains only fields from default fieldset
- print "self.widgets: ", self.widgets._data
Advertisement
Add Comment
Please, Sign In to add comment