Plone z3c.form.GroupForm with inline validation

I am stuck using two schemes to create a z3c.GroupForm that has a built in validation:

Following https://pypi.python.org/pypi/z3c.form#group-forms I did:

from plone.directives.dexterity import AddForm
from z3c.form import field
from z3c.form import group, form

class CustomerGroup( group.Group ):
    label = u'Customer'
    fields = field.Fields(ICustomer, prefix='customer')

class CustomerRegistrationAddForm(group.GroupForm, AddForm):
    ignoreContext = True
    fields = field.Fields(IEmailUser).omit('customer')
    groups = (CustomerGroup,)

      

It works. But it gives me really simple rendering and no inline validation. I tried to enable mixing from plone.autoform but they don't seem to be compatible -> MRO errors.

I'm pretty sure I missed something. There are Plone.app.z3cform and other wrappers for using z3c.form in Plone. But I didn’t find an example of their use for z3c.groups, so I tried the basic z3c option.

I like to do the following: A form that has Scheme A and Scheme B fields each on a tab, respectively. The processing of the form action is then hand-coded and will handle the basic content types. In other words: no dexterity "positive connotation" magic will be used /.

But I like to have inline validation according to the schema hints and adapters that I have registered for the schemas.

+3


source to share


1 answer


The problem has been resolved. Now Z3c groups are called fields in Plone. The following does the trick.



from plone.autoform.form import AutoExtensibleForm
from plone.supermodel import model
from z3c.form import form
from plone.autoform import directives

class ICustomerRegistration( IEmailUser, ICustomer ):
    model.fieldset('EmailUser',
        label=_(u"EMail User"),
        fields=['email', 'firstname', 'lastname', ]
        )

    model.fieldset('Customer',
        label=_(u"Customer"),
        fields=['enterprise',
                'street',
                'house_number',
                'postal_code',
                'city',
                ]
        )

class CustomerRegistrationAddForm(AutoExtensibleForm, form.Form):
    ignoreContext = True
    schema = ICustomerRegistration

      

+2


source







All Articles