mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Change DBCurrency scaffolded form field to CurrencyField (fixes #8246)
Add test ensuring DBCurrency scaffolds CurrencyField
This commit is contained in:
parent
e4d1cf8818
commit
6af736a9e1
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace SilverStripe\ORM\FieldType;
|
namespace SilverStripe\ORM\FieldType;
|
||||||
|
|
||||||
|
use SilverStripe\Forms\CurrencyField;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a decimal field containing a currency amount.
|
* Represents a decimal field containing a currency amount.
|
||||||
* The currency class only supports single currencies. For multi-currency support, use {@link Money}
|
* The currency class only supports single currencies. For multi-currency support, use {@link Money}
|
||||||
@ -67,4 +69,15 @@ class DBCurrency extends DBDecimal
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $title
|
||||||
|
* @param array $params
|
||||||
|
*
|
||||||
|
* @return CurrencyField
|
||||||
|
*/
|
||||||
|
public function scaffoldFormField($title = null, $params = null)
|
||||||
|
{
|
||||||
|
return CurrencyField::create($this->getName(), $title);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace SilverStripe\ORM\Tests;
|
namespace SilverStripe\ORM\Tests;
|
||||||
|
|
||||||
|
use SilverStripe\Forms\CurrencyField;
|
||||||
use SilverStripe\ORM\FieldType\DBCurrency;
|
use SilverStripe\ORM\FieldType\DBCurrency;
|
||||||
use SilverStripe\Dev\SapphireTest;
|
use SilverStripe\Dev\SapphireTest;
|
||||||
|
|
||||||
@ -41,4 +42,13 @@ class DBCurrencyTest extends SapphireTest
|
|||||||
$this->assertEquals($niceValues[1], $c->Whole());
|
$this->assertEquals($niceValues[1], $c->Whole());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testScaffoldedField()
|
||||||
|
{
|
||||||
|
// Test DBCurrency scaffolds a CurrencyField
|
||||||
|
$currencyDbField = DBCurrency::create('Currency');
|
||||||
|
$scaffoldedField = $currencyDbField->scaffoldFormField();
|
||||||
|
|
||||||
|
$this->assertInstanceOf(CurrencyField::class, $scaffoldedField);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user