Definition

address_form_fields($edit = array())
ecommerce-5--3/address/address.module, line 377

Code

<?php
function address_form_fields($edit = array()) {
  if (is_numeric($edit['country'])) {
    // alert users with old-style addresses
    drupal_set_message(t('<strong>Please update your <em>country</em> and <em>state/province</em></strong>.<br />We apologize for the inconvenience.'));
  }
  else if (!$edit['province']) {
    $edit['province'] = $edit['state'];
  }
  $countries = store_build_countries();
  array_unshift($countries, t('Please choose...'));
  $country = ($edit['country'] ? $edit['country'] : variable_get('ec_country', 0));
  $form['country'] = array(
    '#type' => 'select',
    '#title' => t('Country'),
    '#default_value' => ($country),
    '#options' => $countries,
    '#description' => null,
    '#multiple' => false,
    '#required' => true,
  );
  $form['firstname'] = array(
    '#type' => 'textfield',
    '#title' => t('First Name'),
    '#default_value' => $edit['firstname'],
    '#size' => 50,
    '#maxlength' => 75,
    '#description' => null,
    '#attributes' => null,
    '#required' => true,
  );
  $form['lastname'] = array(
    '#type' => 'textfield',
    '#title' => t('Last Name'),
    '#default_value' => $edit['lastname'],
    '#size' => 50,
    '#maxlength' => 75,
    '#description' => null,
    '#attributes' => null,
    '#required' => true,
  );
  $form['street1'] = array(
    '#type' => 'textfield',
    '#title' => t('Address Line 1'),
    '#default_value' => $edit['street1'],
    '#size' => 50,
    '#maxlength' => 75,
    '#description' => null,
    '#attributes' => null,
    '#required' => true,
  );
  $form['street2'] = array(
    '#type' => 'textfield',
    '#title' => t('Address Line 2'),
    '#default_value' => $edit['street2'],
    '#size' => 50,
    '#maxlength' => 75,
    '#description' => null,
    '#attributes' => null,
    '#required' => false,
  );
  $form['city'] = array(
    '#type' => 'textfield',
    '#title' => t('City'),
    '#default_value' => $edit['city'],
    '#size' => 30,
    '#maxlength' => 64,
    '#description' => null,
    '#attributes' => null,
    '#required' => true,
  );
  $states = store_build_states($country);
  array_unshift($states, t('Please choose...'));
  $form['state'] = array(
    '#type' => 'select',
    '#title' => t('State'),
    '#default_value' => $edit['state'],
    '#options' => $states,
    '#description' => null,
    '#extra' => null,
    '#multiple' => false,
    //'#required' => isset($_POST['province']),
    '#prefix' => '<div id="wrapper-state">',
    '#suffix' => '</div>',
  );
  $form['province'] = array(
    '#type' => 'textfield',
    '#title' => t('Province / Region'),
    '#default_value' => $edit['province'],
    '#size' => 30,
    '#maxlength' => 64,
    '#description' => null,
    '#attributes' => null,
    //'#required' => isset($_POST['state']),
    '#prefix' => '<div id="wrapper-province">',
    '#suffix' => '</div>',
  );
  $form['zip'] = array(
    '#type' => 'textfield',
    '#title' => t('Zip / Postal Code'),
    '#default_value' => $edit['zip'],
    '#size' => 20,
    '#maxlength' => 20,
    '#description' => null,
    '#attributes' => null,
    '#required' => true,
  );
  $form['phone'] = array(
    '#type' => 'textfield',
    '#title' => t('Phone Number'),
    '#default_value' => $edit['phone'],
    '#size' => 50,
    '#maxlength' => 100,
    '#description' => null,
    '#attributes' => null,
    '#required' => false,
  );

  if ($edit['aid']) {
    $form['aid'] = array('#type' => 'value', '#value' => $edit['aid']);
  }
  if ($edit['uid']) {
    $form['uid'] = array('#type' => 'value', '#value' => $edit['uid']);
  }

  return $form;
}
?>