address_form_validate

Versions
5
address_form_validate($form_id, $form_values)

Validate an address being saved

Code

contrib-5/ecommerce/address/address.module, line 559

<?php
function address_form_validate($form_id, $form_values) {
  
  // custom var to ignore states
  if ( variable_get('store_ignore_state', FALSE)) {
    return;
  }
  // we need to ensure we have a country
  if ($form_values['country'] == "0" ) {
    form_set_error('country', t('Country is required.'));
  }
  // we need either a province or a state
  if (!$form_values['province'] && !$form_values['state']) {
    form_set_error('state', t('State/province/region is required.'));
    form_set_error('province', '');
  }
}
?>

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options