DirectorDatafieldForm: Add loadObject to fix settings

This commit is contained in:
Alexander Fuhr 2015-07-28 13:20:27 +02:00
parent 45049e45da
commit 9e275a589c
1 changed files with 18 additions and 1 deletions

View File

@ -33,7 +33,9 @@ class DirectorDatafieldForm extends DirectorObjectForm
'class' => 'autosubmit'
));
if ($class = $this->getSentValue('datatype')) {
if ($class = $this->object()->datatype) {
$this->addSettings($class);
} elseif ($class = $this->getSentValue('datatype')) {
if ($class && array_key_exists($class, $this->enumDataTypes())) {
$this->addSettings($class);
}
@ -62,6 +64,21 @@ class DirectorDatafieldForm extends DirectorObjectForm
parent::onSuccess();
}
public function loadObject($id)
{
parent::loadObject($id);
$this->addSettings();
foreach ($this->object()->getSettings() as $key => $val) {
if ($el = $this->getElement($key)) {
$el->setValue($val);
}
}
$this->moveSubmitToBottom();
return $this;
}
protected function enumDataTypes()
{
$hooks = Hook::all('Director\\DataType');