Commit e00af464 authored by KR Moorhouse's avatar KR Moorhouse Committed by GitHub

Merge pull request #3375 from wpninjas/fix-default-calc-decimal-setting

fixes decimal issues
parents 77f8ed7e 1993e8ad
......@@ -237,7 +237,13 @@ class NF_AJAX_Controllers_Submission extends NF_Abstracts_Controller
// Scrub unmerged tags (ie deleted/non-existent fields/calcs, etc).
$eq = preg_replace( '/{([a-zA-Z0-9]|:|_|-)*}/', 0, $eq);
$dec = ( isset( $calc[ 'dec' ] ) && 0 <= $calc[ 'dec' ] ) ? $calc[ 'dec' ] : 2;
/**
* PHP doesn't evaluate empty strings to numbers. So check
* for any string for the decimal place
**/
$dec = ( isset( $calc[ 'dec' ] ) && '' != $calc[ 'dec' ] ) ?
$calc[ 'dec' ] : 2;
$calcs_merge_tags->set_merge_tags( $calc[ 'name' ], $eq, $dec, $this->_form_data['settings']['decimal_point'], $this->_form_data['settings']['thousands_sep'] );
$this->_data[ 'extra' ][ 'calculations' ][ $calc[ 'name' ] ] = array(
'raw' => $calc[ 'eq' ],
......
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