I'm having a similar problem with Form widgets. This code:

class NewCompanyForm:
    class Fields(widgets.WidgetsList):
            company_name = widgets.TextField(label="Company name:")
            user_name = widgets.TextField(label="Desired user name:")
            password = widgets.PasswordField(label="Password:")
            confirm_password = widgets.PasswordField(
                label="Confirm password:")
            first_name = widgets.TextField(label="First name:")
            last_name = widgets.TextField(label="Last name:")
            email = widgets.TextField(label="Email:")

    class Schema(formencode.Schema):
            company_name = validators.UnicodeString(not_empty=True)
            user_name = validators.All(
                validators.PlainText(not_empty=True),
                validators.MinLength(5))
            password = validators.MinLength(5)
            confirm_password = password
            first_name = validators.NotEmpty()
            last_name = validators.NotEmpty()
            email =  validators.Email()
            chained_validators = [validators.FieldsMatch(
                'password', 'password_confirm')]

    form = widgets.TableForm(name="signup", fields=Fields(),
            validator=Schema(), action="new_user", submit_text="Next",
            table_attrs={'width':'100%'})

class NewCompany:
    @expose(template="ris.templates.form")
    def index(self, tg_errors=None):
        pass
        return dict(page_title="Sign Up",
            form_title="Sign up a new company",
            form=NewCompanyForm.form)


    @expose()
    @validate(form=NewCompanyForm.form)
    @error_handler(index)
    def new_user(self, company_name, user_name, password,
        confirm_password, first_name, last_name, email):

        comp = Company(name=company_name,
            neutered_name=neuter(company_name))

        newuser = User(user_name=user_name,first_name=first_name,
            last_name=last_name,email_address=email,
            password=password,company=comp)

        flash("User successfully created!")
        raise cherrypy.HTTPRedirect("index")

does a very strange thing. It seems to work as expected, but validation
is very messed up - instead of normal validation errors like "String
must be not empty", the error fields of every field get populated with
"The input field 'self' was not expected."

Again, not really sure what I'm doing wrong, I'm trying to keep the
form/schema/fields in one place and the controller code in another to
keep it logical.

I'm using the forms like this:

class Root(controllers.RootController):

    login=forms.Login()
    sign_up=forms.NewCompany()


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---

Reply via email to