Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7642635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:14:23+00:00 2026-05-31T09:14:23+00:00

I’m using z3c.form to create a form in Plone 4.1.4. I need a boolean

  • 0

I’m using z3c.form to create a form in Plone 4.1.4. I need a boolean field which is required: the user must tick the box. (In my case, the user must agree to the terms and conditions.)

Using required=True for the field doesn’t work: I can submit the form without checking the checkbox.

This is what my code looks like:

from five import grok
from plone.directives import form
from zope import schema
from z3c.form import button


from Products.CMFCore.interfaces import ISiteRoot
from Products.statusmessages.interfaces import IStatusMessage


class ITestSchema(form.Schema):
    hasApprovedConditions = schema.Bool(
        title=u'I agree to the Terms and Conditions.',
        required=True,
    )


class TestForm(form.SchemaForm):
    grok.name('test-form')
    grok.require('zope2.View')
    grok.context(ISiteRoot)

    schema = ITestSchema
    ignoreContext = True

    @button.buttonAndHandler(u'Send')
    def handleApply(self, action):
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return

        IStatusMessage(self.request).addStatusMessage(u'Thanks', 'info')
        self.request.response.redirect(self.context.absolute_url())

The form shows the checkbox and label, but there is no indication that the field is required and indeed it isn’t: I can submit the form without ticking the checkbox.

I’m extending these known good sets:

  • http://dist.plone.org/release/4.1.4/versions.cfg
  • http://good-py.appspot.com/release/dexterity/1.2?plone=4.1.4

They pin z3c.form to version 2.5.1 but I also tried version 2.6.1.

What am I missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T09:14:24+00:00Added an answer on May 31, 2026 at 9:14 am

    You should use a constraint like this:

    def validateAccept(value):
        if not value == True:
            return False
        return True
    
    class ITestSchema(form.Schema):
        hasApprovedConditions = schema.Bool(
            title=u'I agree to the Terms and Conditions.',
            required=True,
            constraint=validateAccept,
        )
    

    More info:

    • http://plone.org/products/collective.examples.userdata
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to clean up various Word 'smart' characters in user input, including but
I have a text area in my form which accepts all possible characters from
I have thousands of HTML files to process using Groovy/Java and I need to
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.