DirectorDatafieldForm: Add loadObject to fix settings
This commit is contained in:
parent
45049e45da
commit
9e275a589c
|
@ -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');
|
||||
|
|
Loading…
Reference in New Issue