fixed field is null

This commit is contained in:
Pack 2023-09-28 19:06:10 +13:00
parent 071d8b7b09
commit 78df78c584
2 changed files with 12 additions and 8 deletions

1
.gitignore vendored
View File

@ -12,3 +12,4 @@ coverage/
/vendor/
composer.lock
silverstripe-cache/
.idea

View File

@ -268,14 +268,17 @@ class FieldList extends ArrayList
// Add the fields to the end of this set
foreach ($fields as $field) {
// Check if a field by the same name exists in this tab
if ($insertBefore) {
$tab->insertBefore($insertBefore, $field);
} elseif (($name = $field->getName()) && $tab->fieldByName($name)) {
// It exists, so we need to replace the old one
$this->replaceField($field->getName(), $field);
} else {
$tab->push($field);
// Check if field is not null
if($field !== null) {
// Check if a field by the same name exists in this tab
if ($insertBefore) {
$tab->insertBefore($insertBefore, $field);
} elseif (($name = $field->getName()) && $tab->fieldByName($name)) {
// It exists, so we need to replace the old one
$this->replaceField($field->getName(), $field);
} else {
$tab->push($field);
}
}
}