source: products/quintagroup.formlib.captcha/trunk/quintagroup/formlib/captcha/example.py @ 2804

Last change on this file since 2804 was 2804, checked in by mylan, 14 years ago

#195: Fixed form breakage in plone-3.3

  • Property svn:eol-style set to native
File size: 969 bytes
Line 
1from zope.schema import TextLine
2from zope.component import adapts
3from zope.interface import Interface, implements
4from zope.formlib.form import FormFields
5from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
6from plone.app.form.base import EditForm
7
8from quintagroup.formlib.captcha import Captcha
9     
10# Define CaptchaFormlibForm form schema
11
12class ICaptchaFormlibFormSchema(Interface):
13    label = TextLine(title=u'Label')
14    captcha = Captcha(title=u'Type the code')
15     
16# Create adapter for any object to ICaptchaFormlibFormSchema
17# schema interface
18
19class CaptchaFormlibFormAdapter(object):
20    implements(ICaptchaFormlibFormSchema)
21
22    def __init__(self, context):
23        self.context = context
24
25    label = u''
26    captcha = None
27     
28# And at the last define the CaptchaFormlibForm form
29
30class CaptchaFormlibForm(EditForm):
31    template = ViewPageTemplateFile("example.pt")
32    form_fields = FormFields(ICaptchaFormlibFormSchema)
Note: See TracBrowser for help on using the repository browser.