コード例 #1
0
 /**
  * This UT tests if saveInto used customised getters/setters correctly.
  * Saving values for CustomMoney shall go through the setCustomMoney_Test
  * setter method and double the value.
  */
 public function testSetValueViaSetter()
 {
     $o = new MoneyFieldTest_CustomSetter_Object();
     $f = new MoneyField('CustomMoney', 'Test Money Field');
     $f->setValue(array('Currency' => 'EUR', 'Amount' => 123456.78));
     $f->saveInto($o);
     $this->assertEquals(2 * 123456.78, $o->MyMoney->getAmount());
     $this->assertEquals('EUR', $o->MyMoney->getCurrency());
 }
コード例 #2
0
 /**
  * Returns a CompositeField instance used as a default
  * for form scaffolding.
  *
  * Used by {@link SearchContext}, {@link ModelAdmin}, {@link DataObject::scaffoldFormFields()}
  *
  * @param string $title Optional. Localized title of the generated instance
  * @param array $params
  * @return FormField
  */
 public function scaffoldFormField($title = null, $params = null)
 {
     $field = new MoneyField($this->getName());
     $field->setAllowedCurrencies($this->getAllowedCurrencies());
     $field->setLocale($this->getLocale());
     return $field;
 }