A country widget for Archetypes
Project description
A country widget for Archetypes
Adds a new tool, portal_countryutil to the Plone root, which lets you manage a list of areas which may contain several countries from the official ISO-country list via the ZMI. A complete list of areas and their countries is being created at install time.
Provides three widgets which you can use in your own Archetype:
- CountryWidget
the areas and countries defined in the country tool are then rendered as a dropdown (with <optgroup>).
- AreaWidget
provides a dropdown with all areas you have defined.
- MultiCountryWidget
for use with LinesField, lets you select multiple countries
Examples
Here is some code that demonstrates how to use those widgets:
---- YourArcheType.py ---- # Import the widget/s: from Products.ATCountryWidget.Widget import CountryWidget, AreaWidget # Define the field/s in your schema: [...] StringField( 'country', validators=('isValidISOCountry',), widget=CountryWidget(label='Country', provideNullValue=1, # this is default nullValueTitle='-', # this is default omitCountries=None, # this is default, can be a # list of country codes which # are not displayed description='Select a country') ), [... and/or ...] StringField( 'area', widget=AreaWidget(label='Area', provideNullValue=1, # this is default nullValueTitle='-', # this is default description='Select an area') ), [... and/or ...] LinesField( 'countries', widget=MultiCountryWidget(label='Countries', omitCountries=None, # this is default, can be a # list of country codes which # are not displayed description='Select countries') ), [...]
Use without Archetypes
To use your countrylist in a custom page template outside of an Archetype (e.g. in a search form) you can directly use the API the country tool provides:
<select tal:define="countrytool here/portal_countryutils"> <option>Choose...</option> <optgroup label="Western Europe" tal:repeat="area countrytool/listAreas" tal:attributes="label area/name"> <option value="DE" tal:repeat="country area/countries" tal:content="country/name" tal:attributes="value country/isocc">Germany </option> </optgroup> </select>
For more details on how to customize content-types, add custom fields to content-types, see Martin’s tutorial: http://plone.org/documentation/how-to/adding-new-fields-to-smart-folders-search/documentation/tutorial/richdocument/extending-atct
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Hashes for Products.ATCountryWidget-0.2.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68c8025e545080c8c9635eeb9c31ae07494e5068d68721b6c8fd22c1cd3a4373 |
|
MD5 | c403c0ff42bab51fa3a949c73ca9a127 |
|
BLAKE2b-256 | 7a3e7ec7dc7d7dd38d05ee10140681e5d0bf1036721beb92cc6477eb00cf1f5c |