You are here

function currency_form in Currency 5

Same name and namespace in other branches
  1. 6 currency.module \currency_form()
  2. 7 currency.module \currency_form()
1 string reference to 'currency_form'
currency_menu in ./currency.module

File

./currency.module, line 70

Code

function currency_form($data = array()) {

  // Get the saved data from the session, if any
  $amount = $_SESSION['currency_amount'] ? $_SESSION['currency_amount'] : 1;
  $from = $_SESSION['currency_from'] ? $_SESSION['currency_from'] : variable_get('currency_default_from', 'CAD');
  $to = $_SESSION['currency_to'] ? $_SESSION['currency_to'] : variable_get('currency_default_to', 'USD');
  $form['currency_description'] = array(
    '#value' => variable_get('currency_description', t('You can use this form to do currency exchange.')),
  );
  $form['currency_amount'] = array(
    '#type' => 'textfield',
    '#title' => t('Amount'),
    '#default_value' => $amount,
    '#size' => 9,
    '#maxlength' => 9,
    '#description' => t('Amount to convert'),
  );
  $form['currency_from'] = array(
    '#type' => 'select',
    '#title' => t('From'),
    '#default_value' => $from,
    '#options' => currency_api_get_list(),
  );
  $form['currency_to'] = array(
    '#type' => 'select',
    '#title' => t('To'),
    '#default_value' => $to,
    '#options' => currency_api_get_list(),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Convert'),
  );
  return $form;
}