From 8703ace32a0242c822f4bc04c690ca4b12cbc7af Mon Sep 17 00:00:00 2001 From: Bram de Leeuw Date: Mon, 15 Jul 2019 11:15:30 +0200 Subject: [PATCH] validate that a classname had been set --- code/Model/EditableFormField/Validator.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/code/Model/EditableFormField/Validator.php b/code/Model/EditableFormField/Validator.php index 3b7538f..2836a21 100644 --- a/code/Model/EditableFormField/Validator.php +++ b/code/Model/EditableFormField/Validator.php @@ -39,6 +39,18 @@ class Validator extends RequiredFields return false; } + // When the record is unsaved and the classname is not set throw an error + if ((!$this->record || !$this->record->exists()) && (!isset($data['ClassName']) || empty($data['ClassName']))) { + $this->validationError( + 'ClassName', + _t( + __CLASS__ . 'CLASSNAME_ERROR', + 'You need to select a field type before you can create the field' + ) + ); + return false; + } + // Skip unsaved records if (!$this->record || !$this->record->exists()) { return true;