function physical_field_widget_settings_form in Physical Fields 7
Implements hook_field_widget_settings_form().
File
- ./
physical.module, line 184 - Defines fields (e.g. weight and dimensions) to support describing the physical attributes of entities.
Code
function physical_field_widget_settings_form($field, $instance) {
$widget = $instance['widget'];
$settings = array_merge(field_info_widget_settings($widget['type']), $widget['settings']);
$form = array();
// Build the settings for the weight textfield widget.
if ($widget['type'] == 'physical_volume_input') {
$form['default_unit'] = array(
'#type' => 'select',
'#title' => t('Unit of measurement'),
'#options' => physical_volume_unit_options(),
'#default_value' => $settings['default_unit'],
);
$form['unit_select_list'] = array(
'#type' => 'checkbox',
'#title' => t('Allow the user to select a different unit of measurement on forms.'),
'#default_value' => $settings['unit_select_list'],
);
}
elseif ($widget['type'] == 'physical_weight_textfield') {
$form['default_unit'] = array(
'#type' => 'select',
'#title' => t('Unit of measurement'),
'#options' => physical_weight_unit_options(),
'#default_value' => $settings['default_unit'],
);
$form['unit_select_list'] = array(
'#type' => 'checkbox',
'#title' => t('Allow the user to select a different unit of measurement on forms.'),
'#default_value' => $settings['unit_select_list'],
);
}
elseif ($widget['type'] == 'physical_dimensions_textfields') {
$form['default_unit'] = array(
'#type' => 'select',
'#title' => t('Unit of measurement'),
'#options' => physical_dimension_unit_options(),
'#default_value' => $settings['default_unit'],
);
$form['unit_select_list'] = array(
'#type' => 'checkbox',
'#title' => t('Allow the user to select a different unit of measurement on forms.'),
'#default_value' => $settings['unit_select_list'],
);
}
return $form;
}