Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

API CHANGE: Added new config option Money.default_currency.

  • Loading branch information...
commit 7201f0647631b0b6c903831aabc77f1e05032094 1 parent 7036abb
@sminnee sminnee authored
Showing with 5 additions and 3 deletions.
  1. +5 −3 model/fieldtypes/Money.php
View
8 model/fieldtypes/Money.php
@@ -106,9 +106,11 @@ function setValue($value, $record = null, $markChanged = true) {
$this->setCurrency($value->getCurrency(), $markChanged);
$this->setAmount($value->getAmount(), $markChanged);
if($markChanged) $this->isChanged = true;
- } else if($record && isset($record[$this->name . 'Currency']) && isset($record[$this->name . 'Amount'])) {
- if($record[$this->name . 'Currency'] && $record[$this->name . 'Amount']) {
- $this->setCurrency($record[$this->name . 'Currency'], $markChanged);
+ } else if($record && isset($record[$this->name . 'Amount'])) {
+ if($record[$this->name . 'Amount']) {
+ if(!empty($record[$this->name . 'Currency'])) $this->setCurrency($record[$this->name . 'Currency'], $markChanged);
+ else if($currency = (string)$this->config()->get('default_currency')) $this->setCurrency($currency, $markChanged);
+
$this->setAmount($record[$this->name . 'Amount'], $markChanged);
} else {
$this->value = $this->nullValue();
Please sign in to comment.
Something went wrong with that request. Please try again.