You are here

function _range_field_formatter_view_prefix_suffix in Range 7

Helper function. Adds prefix and suffix to the given range field value.

Parameters

string $value: FROM/TO range field value.

bool $display_prefix: Whether to add suffix/prefix or not.

array $instance_settings: Field instance FROM/TO value settings.

Return value

string Range field value with added prefix/suffix.

4 calls to _range_field_formatter_view_prefix_suffix()
RangeUnitTestCase::testRangeFormatterViewPrefixSuffix in tests/range.unit.test
Tests range prefixer/suffixer.
range_field_formatter_view in ./range.module
Implements hook_field_formatter_view().
_range_field_formatter_view_combined_value in ./range.module
Helper function. Returns field markup for combined value option.
_range_field_formatter_view_separate_values in ./range.module
Helper function. Returns field markup for separate values option.

File

./range.module, line 597
Defines range field types.

Code

function _range_field_formatter_view_prefix_suffix($value, $display_prefix, array $instance_settings) {
  if ($display_prefix) {
    $prefix = isset($instance_settings['prefix']) ? field_filter_xss($instance_settings['prefix']) : '';
    $suffix = isset($instance_settings['suffix']) ? field_filter_xss($instance_settings['suffix']) : '';
    return $prefix . $value . $suffix;
  }
  return $value;
}