From 1acf332f6b6308cfd7d555dfd499dad2c7b525eb Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 7 Dec 2016 09:43:16 +0100 Subject: [PATCH] DirectorDataField: whether a field is required... ...is a setting --- library/Director/Objects/DirectorDatafield.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/library/Director/Objects/DirectorDatafield.php b/library/Director/Objects/DirectorDatafield.php index c7ca3296..0120b17a 100644 --- a/library/Director/Objects/DirectorDatafield.php +++ b/library/Director/Objects/DirectorDatafield.php @@ -29,8 +29,6 @@ class DirectorDatafield extends DbObjectWithSettings protected $settingsRemoteId = 'datafield_id'; - private $required = false; - private $object; public static function fromDbRow($row, Db $connection) @@ -56,10 +54,6 @@ class DirectorDatafield extends DbObjectWithSettings return $this->object; } - protected function setRequired($value) - { - $this->required = (bool) $value; - } public function getFormElement(DirectorObjectForm $form, $name = null) { @@ -82,6 +76,9 @@ class DirectorDatafield extends DbObjectWithSettings $datatype->setSettings($this->getSettings()); $el = $datatype->getFormElement($name, $form); + if ($this->getSetting('is_required') === 'y') { + $el->setRequired(true); + } if ($caption = $this->get('caption')) { $el->setLabel($caption); }