You are here

function postal_code_field_widget_info in Postal Code 7

Implements hook_field_widget_info().

File

./postal_code.module, line 143

Code

function postal_code_field_widget_info() {
  require_once DRUPAL_ROOT . "/includes/iso.inc";
  $postal_code_validation_data = postal_code_validation();
  $widgets = array(
    'postal_code_any_postal_code_form' => array(
      'label' => t('Postal Code: Any Format'),
      'field types' => array(
        'postal_code',
      ),
      'behaviors' => array(
        'multiple values' => FIELD_BEHAVIOR_DEFAULT,
        'default value' => FIELD_BEHAVIOR_DEFAULT,
      ),
    ),
  );
  $countrylist = _country_get_predefined_list();
  foreach ($postal_code_validation_data as $country => $regex) {
    $widgets['postal_code_' . $country . '_postal_code_form'] = array(
      'label' => t('Postal Code: @countrylist', array(
        '@countrylist' => $countrylist[drupal_strtoupper($country)],
      )),
      'field types' => array(
        'postal_code',
      ),
      'behaviors' => array(
        'multiple values' => FIELD_BEHAVIOR_DEFAULT,
        'default value' => FIELD_BEHAVIOR_DEFAULT,
      ),
    );
  }
  return $widgets;
}