Description:
A very minimal D7 Postal Code field with validation for one country (listed below) or a combination of countries.
Countries with validation:
USA
Canada
UK
Germany
France
Italy
Australia
Netherlands
Spain
Denmark
Sweden
Belgium
India
To configure this module, navigate to admin/structure/postal_code. Selecting countries in the 'Valid "Any" Countries" list will validate the submitted postal code against regexes for those countries using the "Any Country" widget type. If you want submissions validated, make sure to check the "Validate" checkbox.
To configure content types to add this field type, navigate to admin/structure/types. Select "manage fields" beside the content type (eg: blog, page, article...) and follow the normal procedure to add a new field, choosing "Postal Code" under field type. Beneath "Widget" a number of selections will appear for each country type, as well as an "Any" country which is configurable (see above) to validate any included country's postal code.
Thanks to Pixel Envision and Geeks With Blogs for the list of countries and Classic Graphics for the time to complete it.
Difference from postal_code_validation Module
My module - postal_code provides a feature to create a field of field type postal code with different Field API widgets such as 'Postal Code:Any Format,Postal Code:Canada Format etc'. And there is a configuration form(admin/structure/postal_code) where we select countries to be validated if selected widget type is 'Postal Code: Any Format'.
Whereas postal_code_validation Module provides a validation function which need to be called on #validate attribute of a custom field when building a custom module with country code and data as parameters.
Project Page : http://drupal.org/sandbox/jeremyclassic/1539988
GIT Repo location : http://git.drupal.org/sandbox/jeremyclassic/1539988.git postal_code
Drupal Version : 7.x
Modules Reviewed:
http://drupal.org/node/1676528#comment-6230330
http://drupal.org/node/1680984#comment-6233486
http://drupal.org/node/1683544#comment-6233456
http://drupal.org/node/1670402#comment-6287008
http://drupal.org/node/1676038#comment-6287048
http://drupal.org/node/1603626#comment-6287070
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | postal_code.png | 36.32 KB | sanchi.girotra |
| postal_code.png | 59.48 KB | sanchi.girotra |
Comments
Comment #1
parwan005 commentedHello,
Found few minor issues in your code. Here is the link to your error report.
Will let you know issues, if any after manual review.
Comment #2
sanchi.girotra commentedI have fixed this issue see review report here.
Thanks
Sanchi
Comment #3
mantish commentedHi sanchi.girotra,
Made a manual review of your code just a couple of issues related to t() function.
- On line 88 of postal_code.module you have included HTML tags within t() function, which is wrong. Use HTML tags outside t() function and append the string.
- Have not used t() function on line 83, 93 and 100 of postal_code.module.
Cheers
Mantish
Comment #4
mantish commentedComment #4.0
mantish commentedReviewed Module with #comment-6230330
Comment #5
sanchi.girotra commentedThanks mantish for the review.
I have fixed the issue related to t() on line no 88.
And i have seen core blog module in that their is no t() tag in title so same i am applying in this module and not fixing issues listed in line no. 83,93,100.
Regards
Sanchi
Comment #6
sanchi.girotra commentedApplying for PAReview: review bonus.
Comment #7
misc commentedWelcome with you application.
You have not listed similar projects. How does your module differ from http://drupal.org/project/postal_code_validation? Similarities/differences?
Comment #8
sanchi.girotra commentedDifference
My module - postal_code provides a feature to create a field of field type postal code with different Field API widgets such as 'Postal Code:Any Format,Postal Code:Canada Format etc'. And there is a configuration form(admin/structure/postal_code) where we select countries to be validated if selected widget type is 'Postal Code: Any Format'.
Whereas postal_code_validation Module provides a validation function which need to be called on #validate attribute of a custom field when building a custom module with country code and data as parameters.
Similarities :
Both validates postal code of different countries .
Comment #9
cthiebault commentedI'm not sure to understand why you wrote
$element;in postal_code.module, line 169?Also line 173, you defined
$settings = $widget['settings'];but it is never used.Following Drupal standards, your variable names should use underscore:
$countrylistitems-->$country_list_itemsComment #10
sanchi.girotra commentedCorrections have been made.
Thanks cthiebault for the review.
Comment #11
Enxebre commentedHi sanchi.girotra,
After a quick review of the module i have one question: Wouldn't be possible reaching the same goal, just creating a widget for text-field extending its instance settings (for choose the allowed countries) and with its own validation (postal code validation over the countries chosen) avoiding new global variables and the insertions in db through variable_set;
Why a new field type is necessary?
Thank you!!
Comment #12
patrickd commentedquestions are no issues - therefore no reason to set needs work.
Comment #13
klausimanual review:
Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.
Comment #14
klausiComment #14.0
klausiReviewed Module with #comment 6233486 ,6233456
Comment #15
sanchi.girotra commentedThanks @Klausi for the review,
I have made required changes as per your suggestions.
1. Added the difference in Issue summary and project page.
2. Have removed the global variable and defined the function postal_code_validation() in the module file.
3. Removed hook_install() from .install file.
4.Changed the permission from "
'access arguments' => array('administer users')," to "'access arguments' => array('administer postal code'),".5. Have used use system_settings_form() as
postal_code_admin_settings().6. Replaced "'Postal Code: ' . $countrylist[drupal_strtoupper($country)]," to "
t('Postal Code: @countrylist', array('@countrylist' => $countrylist[drupal_strtoupper($country)]))".Please review the module again.
Comment #15.0
sanchi.girotra commentedUpdated project desc
Comment #16
sanchi.girotra commentedApplying for PAReview: review bonus.
Comment #17
klausimanual review:
Otherwise looks RTBC to me. Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.
Comment #18
sanchi.girotra commentedThanks @klausi for the RTBC.
I have made required changes as per your suggestions :
1.Removed postal_code_regexes.inc.
2.Added t() for translation on line 96 and 106.
3.And also changed postal_code_uninstall() accordingly.
Comment #19
patrickd commentedThe link in your .info is not properly commented out by
;return t($helptext);Never ever put variables directly into t()!
The translation system at localize.drupal.org is only able to detect and translate static strings within t() functions
Your help text can't be translated because of this.
Don't use 0 or 1 for boolean values, always use TRUE and FALSE!
sanchi.girotra, you are already a git vetted user. There's no need to go through this process again...
Comment #20.0
(not verified) commentedReviewed module with #comment-6287008, 6287048, 6287070.