Commit 48076560 authored by yched's avatar yched

#123667 - incorrect code for prefix / suffix in number widgets - thanks RobRoy

parent c21233f8
......@@ -142,7 +142,7 @@ function number_field($op, &$node, $field, &$items, $teaser, $page) {
if (is_array($items)) {
foreach ($items as $delta => $item) {
$error_field = $field['field_name'].']['.$delta.'][value';
$error_field = $field['field_name'] .']['. $delta .'][value';
if ($item['value'] != '') {
if (is_numeric($field['min']) && $item['value'] < $field['min']) {
form_set_error($error_field, t('The value of %name may be no smaller than %min.', array('%name' => t($field['widget']['label']), '%min' => $field['min'])));
......@@ -275,26 +275,12 @@ function number_widget($op, &$node, $field, &$items) {
case 'form':
$form = array();
$prefix = '';
$suffix = '';
$prefixes = explode('|', $field['prefix']);
$suffixes = explode('|', $field['suffix']);
if ($prefixes) {
if (sizeof($prefixes) > 1) {
$prefix = format_plural($item['value'], $prefixes[0], $prefixes[1]);
}
else {
$prefix = $field['prefix'];
}
}
if ($suffixes) {
if (sizeof($suffixes) > 1) {
$suffix = format_plural($item['value'], $suffixes[0], $suffixes[1]);
}
else {
$suffix = $field['suffix'];
}
}
// We take the plural form (if any) for forms.
$prefix = array_pop($prefixes);
$suffix = array_pop($suffixes);
$form[$field['field_name']] = array('#tree' => TRUE);
if ($field['multiple']) {
......@@ -350,7 +336,7 @@ function number_widget($op, &$node, $field, &$items) {
case 'process form values':
// Don't save empty fields.
foreach ($items as $delta => $item) {
$items[$delta]['value'] = preg_replace('@[^-0-9\.]@','',$items[$delta]['value']);
$items[$delta]['value'] = preg_replace('@[^-0-9\.]@', '', $items[$delta]['value']);
}
if ($field['multiple']) {
foreach ($items as $delta => $item) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment