You are here

function _range_update_instance_7005 in Range 7

Instance update callback for 7005 update.

Parameters

array $instance: Field instance.

Return value

bool Whether given instance was updated or not.

1 string reference to '_range_update_instance_7005'
range_update_7005 in ./range.install
Introduces new field formatter.

File

./range.install, line 198
Install, update and uninstall functions for the range field module.

Code

function _range_update_instance_7005(array &$instance) {
  $return = FALSE;
  foreach ($instance['display'] as $view_mode => $display) {
    if ($display['type'] === 'range_unformatted') {
      $instance['display'][$view_mode]['settings'] += array(
        'from_prefix_suffix' => FALSE,
        'to_prefix_suffix' => FALSE,
        'field_prefix_suffix' => FALSE,
      );
      $return = TRUE;
    }
    if (!empty($display['settings']['number_formatter']) && $display['settings']['number_formatter'] === 'sprintf') {
      $instance['display'][$view_mode]['type'] = $display['type'] === 'range_integer' ? 'range_integer_sprintf' : 'range_decimal_sprintf';
      unset($display['settings']['number_formatter'], $display['settings']['thousand_separator'], $display['settings']['decimal_separator'], $display['settings']['scale']);
      $instance['display'][$view_mode]['settings'] = $display['settings'];
      $return = TRUE;
    }
  }
  return $return;
}