Metadata-Version: 1.0
Name: z3c.formwidget.optgroup
Version: 1.2
Summary: An optgroup widget for z3c.form.
Home-page: https://github.com/tmassman/z3c.formwidget.optgroup
Author: Thomas Massmann
Author-email: thomas.massmann@inqbus.de
License: ZPL 2.1
Download-URL: http://pypi.python.org/pypi/z3c.formwidget.optgroup
Description: Introduction
        ============
        
        This package implements a widget that groups select values into optgroups.
        
        
        Usage
        =====
        
        Imagine you have the following schema::
        
        
            class IMySchema(Interface):
                country = schema.Choice(
                    required=True,
                    title=u"Country",
                    vocabulary='countries',
                )
        
                subdivision = schema.Choice(
                    required=True,
                    title=u"State",
                    vocabulary='subdivisions',
                )
        
                region = schema.Choice(
                    required=True,
                    title=u"County",
                    vocabulary='regions',
                )
        
        
        When you create your vocabularies (e.g. using ``SimpleVocabulary``), instead of adding ``SimpleTerm`` items::
        
            ...
            for country in pycountry.countries:
                terms.append(SimpleTerm(value=country.alpha2, token=country.alpha2,
                                        title=country.name))
            ...
        
        
        you add ``OptgroupTerm`` items::
        
            from z3c.formwidget.optgroup.widget import OptgroupTerm
        
            ...
            country_list = countries(context)
            for item in pycountry.subdivisions:
                parent = country_list.getTermByToken(item.country_code).title
                terms.append(OptgroupTerm(value=item.code, token=item.code,
                                          title=item.name, optgroup=parent))
            ...
        
        
        
        In your form, simply assign the ``OptgroupFieldWidget``::
        
            from z3c.formwidget.optgroup.widget import OptgroupFieldWidget
        
            class MyForm(form.Form):
                fields = field.Fields(IMySchema)
        
                fields['subdivision'].widgetFactory = OptgroupFieldWidget
                fields['region'].widgetFactory = OptgroupFieldWidget
        
        Contributors
        ============
        
        Thomas Massmann, Author
        
        Changelog
        =========
        
        1.2 (2012-05-01)
        ----------------
        
        - Fixed wrong html tag for display mode template.
          [Thomas Massmann]
        
        
        1.1 (2012-04-26)
        ----------------
        
        - Always show no value message as first item.
          [Thomas Massmann]
        
        
        1.0.1 (2012-04-14)
        ------------------
        
        - MANIFEST.in was missing some entries.
          [Thomas Massmann]
        
        
        1.0 (2012-04-14)
        ----------------
        
        - Initial release.
          [Thomas Massmann]
        
Keywords: zope zope3 z3c.form
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Web Environment
Classifier: Framework :: Zope3
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)
Classifier: License :: OSI Approved :: Zope Public License
Classifier: Programming Language :: Python
Classifier: Topic :: Software Development :: Libraries :: Python Modules
