function commerce_order_type_form in Commerce Order Types 7
Creation/editing commerce order type form.
File
- ./
commerce_order_types.admin.inc, line 11 - Provides basic order types management functionality.
Code
function commerce_order_type_form($form, &$form_state, $commerce_order_type, $op = 'edit') {
if ($op == 'clone') {
$commerce_order_type->name .= ' (cloned)';
$commerce_order_type->type = '';
}
$form['name'] = array(
'#title' => t('Label'),
'#type' => 'textfield',
'#default_value' => isset($commerce_order_type->name) ? $commerce_order_type->name : '',
'#description' => t('The human-readable name of this commerce order type.'),
'#required' => TRUE,
'#size' => 30,
);
// Machine-readable type name.
$form['type'] = array(
'#type' => 'machine_name',
'#default_value' => isset($commerce_order_type->type) ? $commerce_order_type->type : '',
'#maxlength' => 32,
'#disabled' => $commerce_order_type
->isLocked() && $op != 'clone',
'#machine_name' => array(
'exists' => 'commerce_order_types_order_types',
'source' => array(
'name',
),
),
'#description' => t('A unique machine-readable name for this commerce order type. It must only contain lowercase letters, numbers, and underscores.'),
);
$form['help'] = array(
'#type' => 'textarea',
'#default_value' => isset($commerce_order_type->help) ? $commerce_order_type->help : '',
'#description' => t('Description about the commerce order type.'),
);
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save Order Type'),
'#weight' => 40,
);
if (!$commerce_order_type
->isLocked() && $op != 'add') {
$form['actions']['delete'] = array(
'#type' => 'submit',
'#value' => t('Delete Order Type'),
'#weight' => 45,
'#limit_validation_errors' => array(),
'#submit' => array(
'commerce_order_type_form_submit_delete',
),
);
}
return $form;
}