You are here

function postal_code_help in Postal Code 8

Same name and namespace in other branches
  1. 7 postal_code.module \postal_code_help()

Implements hook_help().

File

./postal_code.module, line 30
Postal Code field type module file

Code

function postal_code_help($route_name, RouteMatchInterface $route_match) {
  if ($route_name == 'help.page.postal_code') {
    $country_list = CountryManager::getStandardList();
    $postal_code_validation_data = PostalCodeValidation::getAllowedValidationPatterns();
    $country_list_items = '';
    foreach ($postal_code_validation_data as $country => $info) {
      $country_list_items .= '<li>' . $country_list[mb_strtoupper($country)] . '</li>';
    }
    $configurl = Url::fromRoute('postal_code.admin')
      ->toString();
    $conturl = Url::fromRoute('entity.node_type.collection')
      ->toString();
    $helptext = <<<EOT
<p>A very minimal D7 Postal Code field with validation for one country (listed below) or a combination of countries.</p>

<p>Countries with validation:
<ul>
  {<span class="php-variable">$country_list_items</span>}
</ul>
</p>
<p>To configure this module, navigate to the <a href="{<span class="php-variable">$configurl</span>}">Structure > Postal Code</a>. 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.</p>
<p>To configure content types to add this field type, navigate to <a href="{<span class="php-variable">$conturl</span>}">Structure > Content Types</a>. 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.</p>
<p>Thanks to <a href="http://www.pixelenvision.com/1708/zip-postal-code-validation-regex-php-code-for-12-countries/">Pixel Envision</a> and <a href="http://geekswithblogs.net/MainaD/archive/2007/12/03/117321.aspx">Geeks With Blogs</a> for the list of countries and <a href="http://www.knowclassic.com">Classic Graphics</a> for the time to complete it.</p>
EOT;
    return t($helptext);
  }
}