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 8327129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:59:58+00:00 2026-06-09T00:59:58+00:00

I’m writing a form with z3c.form and I’d like to add a css class

  • 0

I’m writing a form with z3c.form and I’d like to add a css class to a widget.

So I’m trying to define an upadateWidgets method to add the css class, but I’ve got this error on super() :

2012-08-02 16:17:22 ERROR Zope.SiteErrorLog 1343917042.940.871101881907 http://pin:34180/Plone/alger/etape1
Traceback (innermost last):
  Module ZPublisher.Publish, line 126, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 46, in call_object
  Module z3c.form.form, line 215, in __call__
  Module z3c.form.form, line 208, in update
  Module plone.z3cform.patch, line 21, in BaseForm_update
  Module z3c.form.form, line 149, in update
  Module bsw.inscription.browser.etape1, line 32, in updateWidgets
TypeError: super(type, obj): obj must be an instance or subtype of type

This is the code :

from zope import interface, schema
from z3c.form import form, field, button, validator
import zope.component

from bsw.inscription import inscriptionMessageFactory as _

class IEtape1Schema(interface.Interface):
    # -*- extra stuff goes here -*-

    valide_informations = schema.Bool(
        title=u"J'assure avoir pris connaissance de toutes les informations ci-dessus",
        description=u'',
        required=True,
        readonly=False,
        default=False,
        )


class Etape1(form.Form):

    fields = field.Fields(IEtape1Schema)
    ignoreContext = True

    label = _(u'Etape 1')
    description = _(u'')

    def updateWidgets(self):
        """ Customize widget options before rendering the form. """
        super(Etape1, self).updateWidgets()
        self.fields['valide_informations'].widget.addClass("myClass")

    @button.buttonAndHandler(u'Submit')
    def actionSubmit(self, action):
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return
        pass
        # Put the action handler code here 


class checkBoxValidator(validator.SimpleFieldValidator):
    def validate(self, value):
        if not value:
            raise zope.interface.Invalid(_(u"Vous devez accepter les conditions"))

# Set conditions for which fields the validator class applies
validator.WidgetValidatorDiscriminators(checkBoxValidator, field=IEtape1Schema['valide_informations'])

# Register the validator so it will be looked up by z3c.form machinery

zope.component.provideAdapter(checkBoxValidator)

I’ve read a lot of examples, and I don’t know where I’m wrong…

  • 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-06-09T01:00:00+00:00Added an answer on June 9, 2026 at 1:00 am

    Because there is a lot of re-wrapping going on to make z3c.form forms work with Plone and the main template, your form’s class hierarchy has been changed on registration.

    As a result, super() calls are broken in such forms, and you need to call the unbound method directly:

    def updateWidgets(self):
        """ Customize widget options before rendering the form. """
        form.Form.updateWidgets(self)
        self.fields['valide_informations'].widget.addClass("myClass")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am trying to render a haml file in a javascript response like so:
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a French site that I want to parse, but am running into

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.