You are here

function addressfield_format_address_ch_generate in Address Field 7

1 string reference to 'addressfield_format_address_ch_generate'
address-ch-example.inc in example/plugins/format/address-ch-example.inc

File

example/plugins/format/address-ch-example.inc, line 15

Code

function addressfield_format_address_ch_generate(&$format, $address, $context = array()) {
  if ($address['country'] == 'CH' && $context['mode'] == 'form') {
    $format['locality_block']['postal_code']['#wrapper_id'] = $format['#wrapper_id'];
    $format['locality_block']['postal_code']['#process'][] = 'ajax_process_form';
    $format['locality_block']['postal_code']['#process'][] = 'addressfield_format_address_ch_postal_code_process';
    $format['locality_block']['postal_code']['#element_validate'] = array(
      'addressfield_form_ch_postal_code_validation',
    );
    $format['locality_block']['postal_code']['#ajax'] = array(
      'callback' => 'addressfield_standard_widget_refresh',
      'wrapper' => $format['#wrapper_id'],
    );
  }
  else {
    if (isset($format['locality_block']['postal_code'])) {

      // Cancel the AJAX for forms we don't control.
      $format['locality_block']['postal_code']['#ajax'] = array();
    }
  }
}