function commerce_tax_ui_tax_type_form in Commerce Core 7
Form callback: create or edit a tax type.
Parameters
$tax_type: The tax type array to edit or for a create form an empty tax type array with properties instantiated but not populated.
1 string reference to 'commerce_tax_ui_tax_type_form'
- commerce_tax_ui_menu in modules/
tax/ commerce_tax_ui.module - Implements hook_menu().
File
- modules/
tax/ includes/ commerce_tax_ui.admin.inc, line 324 - Administrative callbacks and form builder functions for the Tax UI module.
Code
function commerce_tax_ui_tax_type_form($form, &$form_state, $tax_type) {
// Store the initial tax type in the form state.
$form_state['tax_type'] = $tax_type;
$form['tax_type'] = array(
'#tree' => TRUE,
);
$form['tax_type']['title'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#default_value' => $tax_type['title'],
'#description' => t('The administrative title of this tax type. It is recommended that this title begin with a capital letter and contain only letters, numbers, and spaces.'),
'#required' => TRUE,
'#size' => 32,
'#field_suffix' => ' <small id="edit-tax-rate-title-suffix">' . t('Machine name: @name', array(
'@name' => $tax_type['name'],
)) . '</small>',
);
if (empty($tax_type['name'])) {
$form['tax_type']['name'] = array(
'#type' => 'machine_name',
'#title' => t('Machine name'),
'#default_value' => $tax_type['name'],
'#maxlength' => 46,
'#required' => TRUE,
'#machine_name' => array(
'exists' => 'commerce_tax_type_load',
'source' => array(
'tax_type',
'title',
),
),
'#description' => t('The machine-name of this tax type. This name must contain only lowercase letters, numbers, and underscores. It must be unique.'),
);
}
$form['tax_type']['display_title'] = array(
'#type' => 'textfield',
'#title' => t('Display title'),
'#default_value' => $tax_type['display_title'],
'#description' => t('The front end display title of this tax type shown to customers. Leave blank to default to the <em>Title</em> from above.'),
'#size' => 32,
);
$form['tax_type']['description'] = array(
'#type' => 'textarea',
'#title' => t('Description'),
'#description' => t('Describe this tax type if necessary. The text will be displayed in the tax type overview table.'),
'#default_value' => $tax_type['description'],
'#rows' => 3,
);
$form['tax_type']['display_inclusive'] = array(
'#type' => 'checkbox',
'#title' => t('Display taxes of this type inclusive in product prices.'),
'#default_value' => $tax_type['display_inclusive'],
);
$form['tax_type']['round_mode'] = array(
'#type' => 'radios',
'#title' => t('Tax amount rounding mode'),
'#description' => t('Specify what type of rounding should occur when tax rates of this type are calculated for the unit price of a line item. Sales taxes will generally not round these amounts at the unit price level, while VAT style taxes will generally round the half up.'),
'#options' => commerce_round_mode_options_list(),
'#default_value' => $tax_type['round_mode'],
);
$form['actions'] = array(
'#type' => 'actions',
'#weight' => 40,
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save tax type'),
);
if (!empty($form_state['tax_type']['name'])) {
$form['actions']['delete'] = array(
'#type' => 'submit',
'#value' => t('Delete tax type'),
'#suffix' => l(t('Cancel'), 'admin/commerce/config/taxes/types'),
'#submit' => array(
'commerce_tax_ui_tax_type_form_delete_submit',
),
'#weight' => 45,
);
}
else {
$form['actions']['submit']['#suffix'] = l(t('Cancel'), 'admin/commerce/config/taxes/types');
}
return $form;
}