mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Compare commits
2 Commits
4d5a5a15a2
...
211c9cb246
Author | SHA1 | Date | |
---|---|---|---|
|
211c9cb246 | ||
|
4631aa0067 |
@ -3285,9 +3285,6 @@ class DataObject extends ModelData implements DataObjectInterface, i18nEntityPro
|
|||||||
/** @var DBField $obj */
|
/** @var DBField $obj */
|
||||||
$table = $schema->tableName($class);
|
$table = $schema->tableName($class);
|
||||||
$obj = Injector::inst()->create($spec, $fieldName);
|
$obj = Injector::inst()->create($spec, $fieldName);
|
||||||
if (is_null($value)) {
|
|
||||||
$value = $obj->getDefaultValue();
|
|
||||||
}
|
|
||||||
$obj->setTable($table);
|
$obj->setTable($table);
|
||||||
$obj->setValue($value, $this, false);
|
$obj->setValue($value, $this, false);
|
||||||
return $obj;
|
return $obj;
|
||||||
|
@ -52,9 +52,10 @@ class DBDatetime extends DBDate implements TemplateGlobalProvider
|
|||||||
public const ISO_DATETIME_NORMALISED = 'y-MM-dd\'T\'HH:mm:ss';
|
public const ISO_DATETIME_NORMALISED = 'y-MM-dd\'T\'HH:mm:ss';
|
||||||
|
|
||||||
private static array $field_validators = [
|
private static array $field_validators = [
|
||||||
DatetimeFieldValidator::class,
|
// Remove parent validator
|
||||||
// disable parent validator
|
|
||||||
DateFieldValidator::class => null,
|
DateFieldValidator::class => null,
|
||||||
|
// Add datetime validator
|
||||||
|
DatetimeFieldValidator::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -111,7 +111,7 @@ class DBDecimal extends DBField
|
|||||||
->setScale($this->decimalSize);
|
->setScale($this->decimalSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function nullValue(): int
|
public function nullValue(): float
|
||||||
{
|
{
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ use SilverStripe\Forms\EmailField;
|
|||||||
use SilverStripe\ORM\FieldType\DBVarchar;
|
use SilverStripe\ORM\FieldType\DBVarchar;
|
||||||
use SilverStripe\Core\Validation\FieldValidation\EmailFieldValidator;
|
use SilverStripe\Core\Validation\FieldValidation\EmailFieldValidator;
|
||||||
use SilverStripe\Forms\FormField;
|
use SilverStripe\Forms\FormField;
|
||||||
use SilverStripe\Forms\NullableField;
|
|
||||||
|
|
||||||
class DBEmail extends DBVarchar
|
class DBEmail extends DBVarchar
|
||||||
{
|
{
|
||||||
@ -16,14 +15,8 @@ class DBEmail extends DBVarchar
|
|||||||
|
|
||||||
public function scaffoldFormField(?string $title = null, array $params = []): ?FormField
|
public function scaffoldFormField(?string $title = null, array $params = []): ?FormField
|
||||||
{
|
{
|
||||||
// Set field with appropriate size
|
|
||||||
$field = EmailField::create($this->name, $title);
|
$field = EmailField::create($this->name, $title);
|
||||||
$field->setMaxLength($this->getSize());
|
$field->setMaxLength($this->getSize());
|
||||||
|
|
||||||
// Allow the user to select if it's null instead of automatically assuming empty string is
|
|
||||||
if (!$this->getNullifyEmpty()) {
|
|
||||||
return NullableField::create($field);
|
|
||||||
}
|
|
||||||
return $field;
|
return $field;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user