Skip to content

Commit

Permalink
Merge pull request pods-framework#3436 from pods-framework/feature/fi…
Browse files Browse the repository at this point in the history
…x-currency-number-validation

Fix Currency/Number validation
  • Loading branch information
sc0ttkclark committed Mar 4, 2016
2 parents 3d8f8cf + a36df18 commit 81d493a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions classes/fields/currency.php
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,8 @@ public function validate( $value, $name = null, $options = null, $fields = null,

$currency_sign = self::$currencies[ $currency ];

$check = str_replace( array( $thousands, $dot, $currency_sign ), array( '', '.', '' ), $value );
$check = str_replace( array( $thousands, $dot, $currency_sign, html_entity_decode( $currency_sign ) ), array( '', '.', '', '' ), $value );
$check = trim( $check );

$check = preg_replace( '/[0-9\.\-]/', '', $check );

Expand Down Expand Up @@ -562,7 +563,8 @@ public function pre_save( $value, $id = null, $name = null, $options = null, $fi

$currency_sign = self::$currencies[ $currency ];

$value = str_replace( array( $thousands, $dot, $currency_sign ), array( '', '.', '' ), $value );
$value = str_replace( array( $thousands, $dot, $currency_sign, html_entity_decode( $currency_sign ) ), array( '', '.', '', '' ), $value );
$value = trim( $value );

$value = preg_replace( '/[^0-9\.\-]/', '', $value );

Expand Down
2 changes: 2 additions & 0 deletions classes/fields/number.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ public function validate ( $value, $name = null, $options = null, $fields = null
}

$check = str_replace( array( $thousands, $dot ), array( '', '.' ), $value );
$check = trim( $check );

$check = preg_replace( '/[0-9\.\-]/', '', $check );

Expand Down Expand Up @@ -395,6 +396,7 @@ public function pre_save ( $value, $id = null, $name = null, $options = null, $f
}

$value = str_replace( array( $thousands, $dot ), array( '', '.' ), $value );
$value = trim( $value );

$value = preg_replace( '/[^0-9\.\-]/', '', $value );

Expand Down

0 comments on commit 81d493a

Please sign in to comment.