function units_field_field_formatter_settings_form in Units of Measurement 7.2
Implements hook_field_formatter_settings_form().
File
- units_field/
units_field.module, line 226 - Provide field type for storing measured values.
Code
function units_field_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
$display = $instance['display'][$view_mode];
$settings = $display['settings'];
$element = array();
switch ($display['type']) {
case 'units_value_expression':
$mathematical_expression = NULL;
if (isset($settings['expression_postfix'])) {
$mathematical_expression = units_mathematical_expression_create_from_postfix($settings['expression_postfix']);
}
$element['expression_postfix'] = array(
'#type' => 'units_mathematical_expression',
'#title' => t('Output as the following'),
'#value_format' => 'postfix',
'#default_value' => $mathematical_expression,
'#description' => t('Specify here mathematical expression. All constant members of this mathematical expression will be replaced by real values from the field data. Leave empty to output in original format.'),
'#allowed_dimension' => units_field_dimension($field),
);
break;
}
return $element;
}