function uc_product_field_settings_form in Ubercart 5
Same name and namespace in other branches
- 6.2 uc_product/uc_product.admin.inc \uc_product_field_settings_form()
Allows store administrators to control what product information is relavent to their store.
See also
uc_product_settings_overview
theme_uc_product_field_settings_form
uc_product_field_settings_form_submit
1 string reference to 'uc_product_field_settings_form'
- uc_product_menu in uc_product/
uc_product.module - Implementation of hook_menu().
File
- uc_product/
uc_product.module, line 1999 - The product module for Ubercart.
Code
function uc_product_field_settings_form() {
$form = array();
$options = array(
'model',
'image',
'display_price',
'list_price',
'cost',
'sell_price',
'weight',
'dimensions',
'add_to_cart',
);
$enabled = variable_get('uc_product_field_enabled', array(
'model' => 'model',
'image' => 'image',
'display_price' => 'display_price',
'sell_price' => 'sell_price',
'add_to_cart' => 'add_to_cart',
));
$weight = variable_get('uc_product_field_weight', array(
'image' => -2,
'display_price' - 1,
'model' => 0,
'list_price' => 2,
'cost' => 3,
'sell_price' => 4,
'weight' => 5,
'dimensions' => 6,
'add_to_cart' => 10,
));
$fields = array();
foreach ($options as $field) {
$fields[$field] = array(
'enabled' => $enabled[$field],
'weight' => $weight[$field],
);
}
uasort($fields, 'uc_weight_sort');
$form['fields'] = array(
'#tree' => true,
);
foreach ($fields as $label => $field) {
$form['fields'][$label]['enabled'] = array(
'#type' => 'checkbox',
'#default_value' => $field['enabled'],
);
$form['fields'][$label]['weight'] = array(
'#type' => 'weight',
'#delta' => 10,
'#default_value' => $field['weight'],
);
}
$form['buttons']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save configuration'),
);
$form['buttons']['reset'] = array(
'#type' => 'submit',
'#value' => t('Reset to defaults'),
);
return $form;
}