mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #8247 from hchokshi/pulls/4/dbcurrency-scaffold-currency-field
Change DBCurrency scaffolded form field to CurrencyField (fixes #8246)
This commit is contained in:
commit
6e00d90783
@ -2,6 +2,8 @@
|
||||
|
||||
namespace SilverStripe\ORM\FieldType;
|
||||
|
||||
use SilverStripe\Forms\CurrencyField;
|
||||
|
||||
/**
|
||||
* Represents a decimal field containing a currency amount.
|
||||
* The currency class only supports single currencies. For multi-currency support, use {@link Money}
|
||||
@ -67,4 +69,15 @@ class DBCurrency extends DBDecimal
|
||||
|
||||
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;
|
||||
|
||||
use SilverStripe\Forms\CurrencyField;
|
||||
use SilverStripe\ORM\FieldType\DBCurrency;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
|
||||
@ -41,4 +42,13 @@ class DBCurrencyTest extends SapphireTest
|
||||
$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…
Reference in New Issue
Block a user