当前位置: 首页>>代码示例>>PHP>>正文


PHP NumericField::dataValue方法代码示例

本文整理汇总了PHP中NumericField::dataValue方法的典型用法代码示例。如果您正苦于以下问题:PHP NumericField::dataValue方法的具体用法?PHP NumericField::dataValue怎么用?PHP NumericField::dataValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NumericField的用法示例。


在下文中一共展示了NumericField::dataValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: saveInto

 /**
  * 30/06/2009 - Enhancement:
  * SaveInto checks if set-methods are available and use them
  * instead of setting the values in the money class directly. saveInto
  * initiates a new Money class object to pass through the values to the setter
  * method.
  *
  * (see @link MoneyFieldTest_CustomSetter_Object for more information)
  *
  * @param DataObjectInterface|Object $dataObject
  */
 public function saveInto(DataObjectInterface $dataObject)
 {
     $fieldName = $this->getName();
     if ($dataObject->hasMethod("set{$fieldName}")) {
         $dataObject->{$fieldName} = DBField::create_field('Money', array("Currency" => $this->fieldCurrency->dataValue(), "Amount" => $this->fieldAmount->dataValue()));
     } else {
         $currencyField = "{$fieldName}Currency";
         $amountField = "{$fieldName}Amount";
         $dataObject->{$currencyField} = $this->fieldCurrency->dataValue();
         $dataObject->{$amountField} = $this->fieldAmount->dataValue();
     }
 }
开发者ID:jacobbuck,项目名称:silverstripe-framework,代码行数:23,代码来源:MoneyField.php

示例2: checkDataFormatting

 /**
  * Test that data loaded in via Form::loadDataFrom(DataObject) will populate the field correctly,
  * and can format the database value appropriately for the frontend
  *
  * @param string $locale
  * @param array $tests
  */
 public function checkDataFormatting($locale, $tests)
 {
     i18n::set_locale($locale);
     $field = new NumericField('Number');
     $form = new Form(new Controller(), 'Form', new FieldList($field), new FieldList());
     $dataObject = new NumericFieldTest_Object();
     foreach ($tests as $input => $output) {
         // Given a dataobject as a context, the field should assume the field value is not localised
         $dataObject->Number = (string) $input;
         $form->loadDataFrom($dataObject, Form::MERGE_CLEAR_MISSING);
         // Test value
         $this->assertEquals($input, $field->dataValue(), "Expected {$input} loaded via dataobject to be left intact in locale {$locale}");
         // Test expected formatted value (Substitute nbsp for spaces)
         $this->assertEquals($this->clean($output), $field->Value(), "Expected {$input} to be formatted as {$output} in locale {$locale}");
     }
 }
开发者ID:nickbooties,项目名称:silverstripe-framework,代码行数:23,代码来源:NumericFieldTest.php

示例3: testEmptyValidator

 /**
  * Test empty values
  */
 public function testEmptyValidator()
 {
     i18n::set_locale('en_US');
     $field = new NumericField('Number');
     $validator = new RequiredFields('Number');
     // Treats '0' as given for the sake of required fields
     $field->setValue('0');
     $this->assertTrue($field->validate($validator));
     $this->assertEquals(0, $field->dataValue());
     // Treat literal 0
     $field->setValue(0);
     $this->assertTrue($field->validate($validator));
     $this->assertEquals(0, $field->dataValue());
     // Should fail the 'required but not given' test
     $field->setValue('');
     $this->assertFalse($field->validate($validator));
     $field->setValue(false);
     $this->assertFalse($field->validate($validator));
 }
开发者ID:jakedaleweb,项目名称:AtomCodeChallenge,代码行数:22,代码来源:NumericFieldTest.php


注:本文中的NumericField::dataValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。