'Integer', 'version' => 100, 'summary' => 'Field that stores an integer', 'permanent' => true, ); } public function ___getCompatibleFieldtypes(Field $field) { $fieldtypes = parent::___getCompatibleFieldtypes($field); foreach($fieldtypes as $type) { if( !$type instanceof FieldtypeInteger && !$type instanceof FieldtypeFloat && $type != 'FieldtypeText') { $fieldtypes->remove($type); } } return $fieldtypes; } public function getBlankValue(Page $page, Field $field) { return ''; } public function sanitizeValue(Page $page, Field $field, $value) { if(is_string($value) && strlen($value) && !is_numeric($value) && !ctype_digit($value)) { $value = preg_replace('/[^\d]/', '', $value); } $value = strlen("$value") ? (int) $value : ''; return $value; } public function getInputfield(Page $page, Field $field) { $inputfield = $this->modules->get('InputfieldInteger'); $inputfield->class = $this->className(); return $inputfield; } public function getDatabaseSchema(Field $field) { $schema = parent::getDatabaseSchema($field); $schema['data'] = 'int NOT NULL'; return $schema; } /* public function ___getConfigInputfields(Field $field) { $inputfields = parent::___getConfigInputfields($field); $field = $this->modules->get('InputfieldInteger'); $field->setAttribute('name', 'minValue'); $field->label = 'Minimum Allowed Value'; $field->setAttribute('value', $field->minValue); $field->setAttribute('size', 20); $field->description = 'The smallest number allowed by this field.'; $inputfields->append($field); $field = $this->modules->get('InputfieldInteger'); $field->setAttribute('name', 'maxValue'); $field->label = 'Maximum Allowed Value'; $field->setAttribute('value', $field->maxValue); $field->setAttribute('size', 20); $field->description = 'The largest number allowed by this field (may not exceed ' . PHP_INT_MAX . ")"; $inputfields->append($field); return $inputfields; } */ }