Compare commits

..

2 Commits

Author SHA1 Message Date
Steve Boyd
211c9cb246
Merge 4631aa0067 into 6bb9a0b33d 2024-10-15 20:59:21 +00:00
Steve Boyd
4631aa0067 NEW Validate DBFields 2024-10-16 09:59:14 +13:00
4 changed files with 4 additions and 13 deletions

View File

@ -3285,9 +3285,6 @@ class DataObject extends ModelData implements DataObjectInterface, i18nEntityPro
/** @var DBField $obj */
$table = $schema->tableName($class);
$obj = Injector::inst()->create($spec, $fieldName);
if (is_null($value)) {
$value = $obj->getDefaultValue();
}
$obj->setTable($table);
$obj->setValue($value, $this, false);
return $obj;

View File

@ -52,9 +52,10 @@ class DBDatetime extends DBDate implements TemplateGlobalProvider
public const ISO_DATETIME_NORMALISED = 'y-MM-dd\'T\'HH:mm:ss';
private static array $field_validators = [
DatetimeFieldValidator::class,
// disable parent validator
// Remove parent validator
DateFieldValidator::class => null,
// Add datetime validator
DatetimeFieldValidator::class,
];
/**

View File

@ -111,7 +111,7 @@ class DBDecimal extends DBField
->setScale($this->decimalSize);
}
public function nullValue(): int
public function nullValue(): float
{
return 0.0;
}

View File

@ -6,7 +6,6 @@ use SilverStripe\Forms\EmailField;
use SilverStripe\ORM\FieldType\DBVarchar;
use SilverStripe\Core\Validation\FieldValidation\EmailFieldValidator;
use SilverStripe\Forms\FormField;
use SilverStripe\Forms\NullableField;
class DBEmail extends DBVarchar
{
@ -16,14 +15,8 @@ class DBEmail extends DBVarchar
public function scaffoldFormField(?string $title = null, array $params = []): ?FormField
{
// Set field with appropriate size
$field = EmailField::create($this->name, $title);
$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;
}
}