Requests | Blesta

Requests

Allow Styling of currency values generated by format() method of CurrencyFormat Helper

T. Chance Vecchitto shared this idea 4 months ago
Under Consideration

Would be nice to be able to pass an additional option parameter to the format() method of CurrencyFormat class. This additional parameter would have the helper wrap NEGATIVE values with a <span> element that can then be styled in a view to show in color, wrapped in parenthesis, etc.

Currently, Blesta wraps the value as follows:

// Wrap the currency code in a span tag

if ($html_wrap_code) {

$value .= ' <span class=\"currency_code\">' . $currency . '</span>';

}

if ($options['html_code']) {

$value = '<span class="currency_value">' . $value . '</span>';

}

I propose an added test for negative value and where the option is set. This would be inserted just above the return $value line:

// value is negative and options['html_wrap_negative'] is true?

if( strpos($value, '-') !== false && $options['html_wrap_negative'] ) {

$value = '<span class="currency_value_negative">' . $value . '</span>';

}

This four-line addition to the format() method allows us to show negative currency values like traditional systems do. By using an added option and a span element with the CSS class name allows others to either take advantage or not.