function uc_product_form_node_type_form_alter in Ubercart 6.2
Same name and namespace in other branches
- 8.4 uc_product/uc_product.module \uc_product_form_node_type_form_alter()
- 7.3 uc_product/uc_product.module \uc_product_form_node_type_form_alter()
Implements hook_form_{$form_id}_alter().
Adds a default image field setting to product content types.
File
- uc_product/
uc_product.module, line 882 - The product module for Ubercart.
Code
function uc_product_form_node_type_form_alter(&$form, &$form_state) {
$type = $form['#node_type'];
if (!uc_product_is_product($type->type)) {
return;
}
$form['uc_product'] = array(
'#type' => 'fieldset',
'#title' => t('Ubercart product settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
// shippable
$form['uc_product']['uc_product_shippable'] = array(
'#type' => 'checkbox',
'#title' => t('Product and its derivatives are shippable.'),
'#default_value' => variable_get('uc_product_shippable_' . $type->type, 1),
'#description' => t('This setting can still be overridden on the node form.'),
'#return_value' => 1,
'#weight' => -5,
);
// image field
if (module_exists('content')) {
$fields = content_types($type->type);
$fields = (array) $fields['fields'];
$options = array(
'' => t('None'),
);
foreach ($fields as $field_name => $field) {
if (strpos($field['widget']['type'], 'image') !== FALSE) {
$options[$field_name] = $field['widget']['label'];
}
}
$form['uc_product']['uc_image'] = array(
'#type' => 'select',
'#title' => t('Product image field'),
'#default_value' => variable_get('uc_image_' . $type->type, NULL),
'#options' => $options,
'#description' => t('The selected field will be used on Ubercart pages to represent the products of this content type.'),
'#weight' => -4,
);
}
}