public function testNumberTypeOnInputHtml()
 {
     $field = new NumericField('Number');
     $html = $field->Field();
     // @todo - Revert to number one day when html5 number supports proper localisation
     // See https://github.com/silverstripe/silverstripe-framework/pull/4565
     $this->assertContains('type="text"', $html, 'number type not set');
 }
 public function Field($properties = array())
 {
     $config = array('showcalendar' => $this->getConfig('showcalendar'), 'isoDateformat' => $this->getConfig('dateformat'), 'jquerydateformat' => DateField_View_JQuery::convert_iso_to_jquery_format($this->getConfig('dateformat')), 'min' => $this->getConfig('min'), 'max' => $this->getConfig('max'));
     // Add other jQuery UI specific, namespaced options (only serializable, no callbacks etc.)
     // TODO Move to DateField_View_jQuery once we have a properly extensible HTML5 attribute system for FormField
     $jqueryUIConfig = array();
     foreach ($this->getConfig() as $k => $v) {
         if (preg_match('/^jQueryUI\\.(.*)/', $k, $matches)) {
             $jqueryUIConfig[$matches[1]] = $v;
         }
     }
     if ($jqueryUIConfig) {
         $config['jqueryuiconfig'] = Convert::array2json(array_filter($jqueryUIConfig));
     }
     $config = array_filter($config);
     foreach ($config as $k => $v) {
         $this->setAttribute('data-' . $k, $v);
     }
     // Three separate fields for day, month and year
     if ($this->getConfig('dmyfields')) {
         // values
         $valArr = $this->valueObj ? $this->valueObj->toArray() : null;
         // fields
         $fieldNames = Zend_Locale::getTranslationList('Field', $this->locale);
         $fieldDay = NumericField::create($this->name . '[day]', false, $valArr ? $valArr['day'] : null)->addExtraClass('day')->setAttribute('placeholder', $this->getConfig('dmyplaceholders') ? $fieldNames['day'] : null)->setMaxLength(2);
         $fieldMonth = NumericField::create($this->name . '[month]', false, $valArr ? $valArr['month'] : null)->addExtraClass('month')->setAttribute('placeholder', $this->getConfig('dmyplaceholders') ? $fieldNames['month'] : null)->setMaxLength(2);
         $fieldYear = NumericField::create($this->name . '[year]', false, $valArr ? $valArr['year'] : null)->addExtraClass('year')->setAttribute('placeholder', $this->getConfig('dmyplaceholders') ? $fieldNames['year'] : null)->setMaxLength(4);
         // order fields depending on format
         $sep = $this->getConfig('dmyseparator');
         $format = $this->getConfig('dateformat');
         $fields = array();
         $fields[stripos($format, 'd')] = $fieldDay->Field();
         $fields[stripos($format, 'm')] = $fieldMonth->Field();
         $fields[stripos($format, 'y')] = $fieldYear->Field();
         ksort($fields);
         $html = implode($sep, $fields);
         // dmyfields doesn't work with showcalendar
         $this->setConfig('showcalendar', false);
     } else {
         $html = parent::Field();
     }
     return $html;
 }
 public function __construct($name, $title = null, $value = '', $extension = null, $areaCode = null, $countryCode = null)
 {
     $this->areaCode = $areaCode;
     $this->ext = $extension;
     $this->countryCode = $countryCode;
     // Build fields
     $fields = new FieldList();
     if ($this->countryCode !== null) {
         $countryField = NumericField::create($name . '[Country]', false, $countryCode, 4)->addExtraClass('phonenumber-field__country');
         $fields->push($countryField);
     }
     if ($this->areaCode !== null) {
         $areaField = NumericField::create($name . '[Area]', false, $areaCode, 4)->addExtraClass('phonenumber-field__area');
         $fields->push($areaField);
     }
     $numberField = NumericField::create($name . '[Number]', false, null, 10)->addExtraClass('phonenumber-field__number');
     $fields->push($numberField);
     if ($this->ext !== null) {
         $extensionField = NumericField::create($name . '[Extension]', false, $extension, 6)->addExtraClass('phonenumber-field__extension');
         $fields->push($extensionField);
     }
     parent::__construct($title, $fields);
     $this->setName($name);
     if (isset($value)) {
         $this->setValue($value);
     }
 }
 public function setForm($form)
 {
     $this->fieldCurrency->setForm($form);
     $this->fieldAmount->setForm($form);
     return parent::setForm($form);
 }