Skip to content
Snippets Groups Projects
Commit fc755aed authored by Angie Byron's avatar Angie Byron
Browse files

#566134 by mfb: Fix bug causing decimal places not to be saved in number module.

parent b47e6801
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -39,7 +39,7 @@ function number_field_info() {
'number_decimal' => array(
'label' => t('Decimal'),
'description' => t('This field stores a number in the database in a fixed decimal format.'),
'settings' => array('precision' => 10, 'scale' => 2, 'decimal' => ' .'),
'settings' => array('precision' => 10, 'scale' => 2, 'decimal' => '.'),
'instance_settings' => array('min' => '', 'max' => '', 'prefix' => '', 'suffix' => ''),
'default_widget' => 'number',
'default_formatter' => 'number_integer',
......@@ -480,7 +480,7 @@ function number_decimal_validate($element, &$form_state) {
form_set_error($error_field, t('Only numbers and the decimal character (%decimal) are allowed in %field.', array('%decimal' => $field['settings']['decimal'], '%field' => t($instance['label']))));
}
else {
$value = str_replace($field['settings']['decimal'], ' .', $value);
$value = str_replace($field['settings']['decimal'], '.', $value);
$value = round($value, $field['settings']['scale']);
form_set_value($element[$field_key], $value, $form_state);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment