Campi Moduli Italiani
Plugin to create useful fields for Italian sites, to be used in the forms produced with Contact Form 7 and WPForms.
Install in
This plugin creates form tags for Contact Form 7 and form fields for WPForms.
Contact Form 7
6 form-tags (and corresponding mail-tags) are available in this version:
* [comune]: creates a series of select for the selection of an Italian municipality
* [comunetext]: (since 2.4.0) creates a text field to type an Italian municipality and choose it from a list of suggestions
* [cf]: creates a field for entering the Italian tax code of a natural person
* [stato]: creates the ability to select a country
* [statotext]: (since 2.4.0) creates a text field to type a country and choose it from a list of suggestions
* [formsign]: creates the possibility to digitally sign the e-mails sent with a private key attributed to each individual form
WPForms
4 fields types are available:
* Cascade selection of an Italian municipality (returning Istat’s municipality code as value)
* “Municipality (text)”: (since 2.4.0) a text field to type an Italian municipality and choose it from a list of suggestions, with the same options of the cascade selection (returning Istat’s municipality code as raw value)
* A field to select a state (since 2.4.0 the country name is the value shown in e-mails and smart tags, Istat’s country code is the raw value)
* “Country (text)”: (since 2.4.0) a text field to type a country and choose it from a list of suggestions (returning Istat’s country code as raw value)
Shortcodes
The fields can also be used outside of the forms, with these shortcodes: [comune], [comunetext] (since 2.4.0), [stato] (since 2.4.0) and [statotext] (since 2.4.0).
Data used
At the time of activation, the plugin downloads the data it uses from the ISTAT SITUAS services (https://situas.istat.it). This data can be updated from the administration console, which also shows when ISTAT has published changes.
Downloading and entering data into the database takes a few minutes: be patient during the activation phase.
The selection of the municipalities was created starting from the code of https://wordpress.org/plugins/regione-provincia-comune/
This plugin uses data made available by ISTAT through the SITUAS portal.
In particular, data from these SITUAS reports are acquired and stored:
- List of codes and names of the territorial units (current municipalities)
- Suppressed or ceded municipalities
- Administrative and territorial changes since 1991
- List of codes and names of the foreign territorial units (countries)
The list of foreign countries ceased since 1990 is distributed with the plugin; an automated test checks it against the SITUAS report of historical foreign countries.
The data published by ISTAT are covered by a Creative Commons license – Attribution (CC-by) (https://creativecommons.org/licenses/by/3.0/it/), as indicated here: https://www.istat.it/it/note-legali
The cadastral codes of the municipalities, used to check the place of birth in the tax code, are published by ISTAT as an elaboration on data of the Agenzia delle entrate (Italian revenue agency).
By Italian law (art. 52 d.lgs. 82/2005) all data, that are not personal data, published by an Italian administration without an explicit license are open data (CC0).
This plugin uses the cadastral codes exclusively for the purpose of carrying out a formal regularity check of the personal tax code.
This plugin does not include any links to the ISTAT’s website on the external pages of the website on which it is used; in particular, no kind of direct link is made, nor of deep linking.
How to use form tags in Contact Form 7
The text fields [comunetext] and [statotext] (since 2.4.0) are an alternative to the select fields: the user types a few letters and chooses from a list of suggestions, using the mouse or the keyboard. They are accessible (WAI-ARIA combobox pattern) and they do not use external libraries.
[comune]
[comune] has a manager in the CF7 form creation area that allows you to set various options.
In particular, it is possible to set the “kind” attribute to “tutti” (all); “attuali” (current), “evidenza_cessati” (evidence ceased). In the first and third cases, in different ways, both the currently existing municipalities and those previously closed are proposed (useful, for example, to allow the selection of the municipality of birth). In the “attuali” mode, however, only the selection of the currently existing municipalities is allowed (useful to allow the selection of the Municipality of residence / domicile).
It is also possible to set the “comu_details” option, to show an icon after the select cascade that allows the display of a modal table with the statistical details of the territorial unit.
The value returned by the group is always the ISTAT code of the selected municipality. The corresponding mail-tag converts this value into the name of the municipality followed by the indication of the automotive code of the province.
From version 1.1.1 hidden fields are also populated with the strings corresponding to the denomination of the region, province and municipality selected, useful for being used in plugins that directly capture the data transmitted by the form (such as “Send PDF for Contact Form 7” )
The cascade of select can also be used outside of CF7, using the [comune] shortcode (options similar to those of the form tag for Contact Form 7).
Starting from version 2.2.0 there is a new filters’ builder for the field [comune] useful for creating fields that allow the selection of a customizable list of municipalities.
Filters can be used both for CF7 tag, and for WPForms field, and for the shortcode ‘comune’.
A short youtube video illustrates how to use filters and the filters’ builder.
[comunetext]
[comunetext] (since 2.4.0) has a manager in the CF7 form creation area. It accepts the same options of [comune]: “kind” (“tutti”, “attuali”, “evidenza_cessati”), “filtername” (a filter created with the filters’ builder), “comu_details”, “use_label_element”, id, class and wrapper class. The default value can be the ISTAT code or the name of the municipality; the “placeholder” option uses it as placeholder.
The field shows a text input with a list of suggestions: municipalities with the same name are distinguished by the automotive code of the province, ceased municipalities are marked.
The value returned is always the ISTAT code of the selected municipality, as for [comune]; the corresponding mail-tag converts it into the name of the municipality followed by the automotive code of the province. Hidden fields with the same suffixes of [comune] (_formatted, _targa, _reg_desc, _prov_desc) are also populated.
If the user types the name without choosing a suggestion (or JavaScript is not available), the text is resolved on the server when it matches a single municipality; otherwise the user is asked to choose from the list.
The field can also be used outside of CF7, using the [comunetext] shortcode (attributes: name, kind, filtername, id, comu_details, class, use_label_element, value, placeholder).
[cf]
[cf] has a manager in the CF7 form creation area that allows you to set the various options.
In particular, it is possible to set various validation options allowing you to find the correspondence of the tax code with other fields of the form.
Specifically, it is possible to verify that the tax code corresponds with the foreign state of birth (selected by means of a select [stato] or a text field [statotext]), the Italian municipality of birth (selected by means of a cascade of select [comune] or a text field [comunetext]), gender (indicating the name of a form field that returns “M” or “F”), the date of birth. If multiple fields are used to select the date of birth, one for the day, one for the month and one for the year, it is possible to find the correspondence of the tax code with these values.
[stato]
[stato] has a manager in the CF7 form creation area that allows you to set various options.
In particular, it is possible to set the selection of only the currently existing states (“only_current” option) and it is possible to set the “use_continent” option to have the select values divided by continent. The field always returns the ISTAT code of the foreign state (code 100 for Italy). The ISTAT code is the type of data expected by [cf], for the verification of the tax code.
The same select can also be used outside of CF7, using the [stato] shortcode (attributes: name, id, class, use_label_element, first_as_label, use_continent, only_current, value).
[statotext]
[statotext] (since 2.4.0) has a manager in the CF7 form creation area. It accepts the options of [stato]: “only_current”, “use_continent” (here the continent is shown next to the name of each suggestion) and “first_as_label” (here it becomes the placeholder “Select a Country”), plus “use_label_element”, id, class and wrapper class. The default value can be the ISTAT code or the Italian name of the country; the “placeholder” option uses it as placeholder.
Countries can be searched by Italian name, alternative name, name in another language or ISO code (for example “USA” or “DE”); ceased countries are marked with “(ceased)”. The list of countries is sent with the page and filtered in the browser, without requests to the server while typing.
The value returned is always the ISTAT code of the country, as for [stato], so the field can be used with [cf] to check the country of birth; the corresponding mail-tag converts it into the name of the country.
The field can also be used outside of CF7, using the [statotext] shortcode (attributes: name, id, class, use_label_element, only_current, use_continent, value, placeholder).
[formsign]
[formsign] NOW (v. 2.2.1) has a manager in the CF7 form creation area.
To use it, simply insert the tag followed by the field name in your own form: for example [formsign firmadigitale]. This tag will create a hidden field in the form with attribute name = “firmadigitale” and no value.
To use the code, it is also necessary to insert the [firmadigitale] mail-tag in the email or emails that the form sends (it is recommended at the end of the email).
In this way, in the email body it will be written a two-lines sequence containing:
an md5 hash of the data transmitted with the module (not of the content of any attached files)
a digital signature of the hash.
If you use html email, you can style the output using a wp option named: “gcmi-forsign-css” with a css as value.
The signature is affixed by generating a pair of RSA keys, attributed to each form.
By checking the hash and the signature, it will be possible to verify that the emails have actually been sent by the form and that the data transmitted by the user correspond to what has been registered.
To facilitate data feedback, it is preferable to use “Flamingo” for archiving sent messages. In fact, in the Flamingo admin screen, a specific box is created that allows feedback of the hash and the digital signature entered in the email.
The system is useful in the event that through the form it is expected to receive applications for registration or applications etc… and avoids disputes regarding the data that the candidates claim to have sent and what is recorded by the system in Flamingo.
Code
Want to check the code? https://github.com/MocioF/campi-moduli-italiani
Written by Joobi from the project's own listing. See the source page
2.4.0
- New [comunetext] form-tag for Contact Form 7, [comunetext] shortcode and “Municipality (text)” field for WPForms: a text field to type an Italian municipality and choose it from a list of suggestions, with the options of [comune] (kind, filters, municipality details); it sends the ISTAT code of the municipality
- The municipality details of the [comune] field open in a native : jQuery UI (dialog and effects) and its stylesheet are no longer loaded in the frontend
- The confirmation and message windows of the filter builder use a native instead of jQuery UI
- The tabs of the filter builder follow the WAI-ARIA tabs pattern with the WordPress admin look; jQuery UI is no longer used and its bundled themes have been removed
- [stato]: with the only_current option, codes of ceased countries are now rejected also by the server-side validation (CF7 and WPForms); the WPForms field now checks that the code sent is a valid country code
- New [statotext] shortcode: a text field to type a country and choose it from a list of suggestions (current and ceased countries, or only current ones); it sends the ISTAT country code like the [stato] field
- New [stato] shortcode, with the same select of the CF7 form-tag; the default value of [stato] can be the Italian name of the country also without the use_continent option
- New [statotext] form-tag for Contact Form 7, with the options of [stato] (only_current, use_continent, first_as_label as placeholder); it can be used with [cf] to check the country of birth
- [stato] (CF7 form-tag and shortcode): ceased countries are marked with “(ceased)” after the name, as in [statotext]; a ceased country with the same code of a current one is no longer listed
- [stato] WPForms field: the field sends the ISTAT code of the country; the e-mail and the smart tags still show the country name, the code is in the raw value (value_raw); ceased countries are marked with “(ceased)”; fixed the default value with the “Split States for continents” option
- New “Country (text)” field for WPForms: a text field to type a country and choose it from a list; it sends the ISTAT code (raw value) and shows the country name in e-mails and smart tags
- No more deprecation notices with Contact Form 7 6.2: the SWV rules are added with WPCF7_SWV_Schema::addRule() when available
- The WPForms “State” field now saves the ISTAT country code as raw value (value_raw); e-mails and smart tags still show the country name. Check any integration that reads the raw value of this field.
2.3.3
- Data of current, suppressed and changed municipalities and of foreign countries are downloaded from the ISTAT SITUAS services; updates are detected through ETag
- The list of ceased foreign countries is distributed with the plugin
- [cf]: the place of birth is checked against the cadastral codes linked to the ISTAT code of the municipality (fixes municipalities with the same name); the table downloaded from the Agenzia delle entrate website has been removed
- New data: tax code of the municipality, cadastral codes of suppressed municipalities and of changes, alternative names and ISO numeric code of countries
- Added the “RN” (renumbering of the statistical code) change type
- The admin page shows the status of the remote source and links to the SITUAS report metadata
- Support for the Schema-Woven Validation of Contact Form 7 6.2
- Removed downloads of zip files, the wget fallback and the bundled certificates
- The PHP extension mbstring is now required; zip, dom and libxml are no longer required
2.3.2
- Fixes issue #14
2.3.1
- Update external servers pem chains
2.3.0
- Move selects to Schema-Woven Validation
- Remove legacy code
- Moving CF7 tag generator to v.2
- Add checks on minimum CF7 and WPForms versions before load integrations
2.2.5
- Fixed use of wpforms Smart Tags
- Update external servers pem chains
2.2.4
- Enhancement in activation requirement checks
- Fixed a validation’s error string in module [cf]
- Fixed error due to missing CSV in archive deployed by data provider
2.2.3
- Fix error in the order of provinces when the module shows only actual municipalities
2.2.2
- Fix bug in cf validation against birth nation
2.2.1
- Fix js for comune [comune]
- Minor bugs fixed
2.2.0
- Added new filter builder for module [comune]
2.1.5
- Update comuni_attuali structure to new dataset
- Added a check on data format before parsing
2.1.4
- Update URL for cadastrial codes
- Updated istat.it pem chain
2.1.3
- Updated www1.agenziaentrate.gov.it pem chain
- Updated istat.it pem chain
2.1.2
- Updated agenziaentrate.gov.it pem chain
- Updated agenziaentrate’s data url
2.1.1
- Updated PEM chains
- Added a wget fallback to download from Istat’s website
2.1.0
- Changed method to get remote file update time on ISTAT website from HEAD to GET
- Fixed bug in wpforms allowing form submission without a full selection of a municipality (marked as compulsory)
- Secured comune’s ajax with nonce
- Added use of WordPress Object Cache to db queries
- Fixed markup changes in form control for CF7 v.5.6
- Added default value in wpforms for “stato”; changed order of choices (now using denominations)
- Added multisite activation feature
- Switch to minified scripts and styles
- Default value in CF7 comune form-tag can be set by municipality’s name
- Added default value in wpforms for “comune”
2.0.8
- Fixed bug in cf atts
2.0.7
- Updated to work in Contact Form 7 > 5.5
- Minor bugs fixed
2.0.6
- Fixed ssl issue in checking last update date of remote files on ISTAT website
2.0.5
- Added new istat.it ca cert for cUrl. Fixes: https://wordpress.org/support/topic/attivazione-vietata-forbidden/
2.0.3
- Minor bug fixes Fixes #1.
2.0.2
- Use the remote update date of comuni_attuali to set the remote update date of codici_catastali
2.0.1
- Minor bug fixes
2.0.0
- added a field to select a municipality to WPForms
- removed variable definition from global scope
- added use of options’ groups in country selection
1.3.0
- first integration with wpforms
1.2.2
- modified table _comuni_variazioni (ISTAT changed the file’s format)
- modified table _comuni_soppressi (ISTAT changed the file’s format)
- updated jquery-ui-dialog.css to version used in WP 5.6
- added standard wpcf7’s classes to [comune] (wpcf7-select), [stato] (wpcf7-select) and [cf] (wpcf7-text)
- changed behaviour of option “use_label_element” in [comune]: if not set, no strings will be shown before selects
- changed previous first elements used as labels in selects of [comune]
- added option to use a label in [stato] (Select a Country)
- changed class name: gcmi_wrap to gcmi-wrap
- for [comune] it is now possible to set custom classes both for the span container and for the selects
- [comune] shortcode (not for CF7):
- changed class name: gcmi_comune to gcmi-comune
- added options “use_label_element”; default to true
- removed p and div tags
1.2.1
- Bug fix: fixed [stato] not replacing mail-tag with contry name
1.2.0
- Added support for default values from the context in [comune], [cf] and [stato]. Contact Form 7 standard sintax is used. Read: https://contactform7.com/getting-default-values-from-the-context/
- Minor bug fixes
1.1.3
- Minor bug fixes
1.1.2
- Fixed charset for https://www.istat.it/storage/codici-unita-amministrative/Elenco-comuni-italiani.csv (data set “comuni_attuali”, table _gcmi_comuni_attuali). Please update the table from admin console if some names have characters mismatch
- Minor bug fix in class-gcmi-comune.php
1.1.1
- Added hidden fields that contain the name of the municipality, province and region selected to be used within plugins that create PDFs
- Set set_time_limit (360) in the activation routine
- Added readme.txt in English
1.1.0
- Modified email signature check: the form ID is determined directly from Flamingo data and is no longer entered in the body of the email
- Insert links to reviews and support page on the plugin page
- Modified “comuni attuali” database import routines, following modification in ISTAT files since June 2020
- Modified remote file update detection system
1.0.3
- Bug fix: error in hash calculation on modules/formsign/wpcf7-formsign-formtag.php
1.0.2
- Updates of some translation strings.
- Bug fix (addslashes before calculating verification hash)
1.0.1
- Updated the text domain to the slug assigned by wordpress.
1.0.0
- First release of the plugin.
Follow this listing's changes (Atom feed)