diff --git a/library/Director/Web/Form/DirectorObjectForm.php b/library/Director/Web/Form/DirectorObjectForm.php index 04d31ece..b24702ae 100644 --- a/library/Director/Web/Form/DirectorObjectForm.php +++ b/library/Director/Web/Form/DirectorObjectForm.php @@ -271,10 +271,18 @@ abstract class DirectorObjectForm extends QuickForm protected function addField($field, $value = null, $inherited = null, $inheritedFrom = null) { $datafield = DirectorDatafield::load($field->datafield_id, $this->getDb()); - $datatype = new $datafield->datatype; - $datatype->setSettings($datafield->getSettings()); - $name = 'var_' . $datafield->varname; + $className = $datafield->datatype; + + if (! class_exists($className)) { + $this->addElement('text', $name, array('disabled' => 'disabled')); + $el = $this->getElement($name); + $el->addError(sprintf('Form element could not be created, %s is missing', $className)); + return $el; + } + + $datatype = new $className; + $datatype->setSettings($datafield->getSettings()); $el = $datatype->getFormElement($name, $this); $el->setLabel($datafield->caption);