| 1 |
<?php
|
| 2 |
// $Id: cck.number.inc,v 1.5 2009/02/03 19:53:47 karens Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* Implementation of hook_field_settings_form() on behalf of core Number module.
|
| 6 |
*/
|
| 7 |
function number_field_settings_form($field) {
|
| 8 |
$form = array();
|
| 9 |
if ($field['type'] == 'number_decimal') {
|
| 10 |
$form['precision'] = array(
|
| 11 |
'#type' => 'select',
|
| 12 |
'#options' => drupal_map_assoc(range(10, 32)),
|
| 13 |
'#title' => t('Precision'),
|
| 14 |
'#description' => t('The total number of digits to store in the database, including those to the right of the decimal.'),
|
| 15 |
'#default_value' => $field['settings']['precision'],
|
| 16 |
);
|
| 17 |
$form['scale'] = array(
|
| 18 |
'#type' => 'select',
|
| 19 |
'#options' => drupal_map_assoc(range(0, 10)),
|
| 20 |
'#title' => t('Scale'),
|
| 21 |
'#description' => t('The number of digits to the right of the decimal.'),
|
| 22 |
'#default_value' => $field['settings']['scale'],
|
| 23 |
);
|
| 24 |
$form['decimal'] = array(
|
| 25 |
'#type' => 'select',
|
| 26 |
'#options' => array('.' => 'decimal point', ',' => 'comma', ' ' => 'space'),
|
| 27 |
'#title' => t('Decimal marker'),
|
| 28 |
'#description' => t('The character users will input to mark the decimal point in forms.'),
|
| 29 |
'#default_value' => $field['settings']['decimal'],
|
| 30 |
);
|
| 31 |
}
|
| 32 |
return $form;
|
| 33 |
}
|
| 34 |
|
| 35 |
function number_field_instance_settings_form($field, $instance) {
|
| 36 |
$widget = $instance['widget'];
|
| 37 |
$field_type = field_info_field_types($field['type']);
|
| 38 |
$defaults = field_info_instance_settings($field['type']);
|
| 39 |
$settings = array_merge($defaults, $instance['settings']);
|
| 40 |
|
| 41 |
$form['min'] = array(
|
| 42 |
'#type' => 'textfield',
|
| 43 |
'#title' => t('Minimum'),
|
| 44 |
'#element_validate' => array('_element_validate_number'),
|
| 45 |
'#default_value' => $instance['settings']['min'],
|
| 46 |
'#description' => t('The minimum value that should be allowed in this field. Leave blank for no minimum.')
|
| 47 |
);
|
| 48 |
$form['max'] = array(
|
| 49 |
'#type' => 'textfield',
|
| 50 |
'#title' => t('Maximum'),
|
| 51 |
'#element_validate' => array('_element_validate_number'),
|
| 52 |
'#default_value' => $instance['settings']['max'],
|
| 53 |
'#description' => t('The maximum value that should be allowed in this field. Leave blank for no maximum.')
|
| 54 |
);
|
| 55 |
$form['prefix'] = array(
|
| 56 |
'#type' => 'textfield',
|
| 57 |
'#title' => t('Prefix'),
|
| 58 |
'#size' => 60,
|
| 59 |
'#default_value' => $instance['settings']['prefix'],
|
| 60 |
'#description' => t('Define a string that should be prefixed to the value, like $ or €. Leave blank for none. Separate singular and plural values with a pipe (pound|pounds).'),
|
| 61 |
);
|
| 62 |
$form['suffix'] = array(
|
| 63 |
'#type' => 'textfield',
|
| 64 |
'#title' => t('Suffix'),
|
| 65 |
'#size' => 60,
|
| 66 |
'#default_value' => $instance['settings']['suffix'],
|
| 67 |
'#description' => t('Define a string that should suffixed to the value, like m², m/s², kb/s. Leave blank for none. Separate singular and plural values with a pipe (pound|pounds).'),
|
| 68 |
);
|
| 69 |
return $form;
|
| 70 |
}
|