1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 20:58:30 +01:00

Fix for custom fields loading in edit mode.

This commit is contained in:
Cameron 2017-01-24 20:31:58 -08:00
parent 71d531be2d
commit 46cacf5e3f
2 changed files with 20 additions and 11 deletions

View File

@ -729,7 +729,7 @@ class page_admin_ui extends e_admin_ui
if(!empty($row['chapter_fields'])) if(!empty($row['chapter_fields']))
{ {
$this->chapterFields[$cat] = e107::unserialize($row['chapter_fields']); $this->chapterFields[$cat] = ($row['chapter_fields']);
} }
@ -799,7 +799,7 @@ class page_admin_ui extends e_admin_ui
if(!empty($this->chapterFields[$chap])) if(!empty($this->chapterFields[$chap]))
{ {
e107::getCustomFields()->loadConfig($this->chapterFields[$chap])->setTab($tabId, "Additional")->setAdminUIConfig('page_fields',$this); e107::getCustomFields()->setTab($tabId, "Additional")->loadConfig($this->chapterFields[$chap])->setAdminUIConfig('page_fields',$this);
} }
else else
{ {
@ -807,6 +807,19 @@ class page_admin_ui extends e_admin_ui
} }
} }
private function loadCustomFieldsData()
{
$row = e107::getDb()->retrieve('page', 'page_chapter, page_fields', 'page_id='.$this->getId());
$cf = e107::getCustomFields();
$cf->loadData($row['page_fields'])->setAdminUIData('page_fields',$this);
// e107::getDebug()->log($cf);
}
function CreateObserver() function CreateObserver()
{ {
@ -827,7 +840,7 @@ class page_admin_ui extends e_admin_ui
$chap = intval($row['page_chapter']); $chap = intval($row['page_chapter']);
$this->initCustomFields($chap); $this->initCustomFields($chap);
e107::getCustomFields()->loadData($row['page_fields'])->setAdminUIData('page_fields',$this); $this->loadCustomFieldsData();
} }

View File

@ -311,10 +311,11 @@
$ui->addTab($tabKey, $this->_tab[$tabKey]); $ui->addTab($tabKey, $this->_tab[$tabKey]);
foreach($this->_config as $key=>$fld) foreach($this->_config as $k=>$fld)
{ {
$fld['tab'] = $tabKey; $fld['tab'] = $tabKey;
$fld['data'] = false; $fld['data'] = false;
$key = $fld['key'];
if($fld['type'] === 'icon') if($fld['type'] === 'icon')
{ {
@ -333,8 +334,6 @@
$fields[$fieldName.'__'.$key] = $fld; $fields[$fieldName.'__'.$key] = $fld;
//$model->fields[$fieldName.'__'.$key] = $fld;
} }
$ui->setFieldAttr($fields); $ui->setFieldAttr($fields);
@ -352,21 +351,18 @@
*/ */
public function setAdminUIData($fieldname, e_admin_ui &$ui) public function setAdminUIData($fieldname, e_admin_ui &$ui)
{ {
// $model->getModel()->set($fieldname, null);
// e107::getCustomFields()->setData($row['page_fields']);
$ui->getModel()->set($fieldname, null); $ui->getModel()->set($fieldname, null);
foreach($this->_data as $key=>$value) foreach($this->_data as $key=>$value)
{ {
$ui->getModel()->set($fieldname.'__'.$key, $value); $ui->getModel()->set($fieldname.'__'.$key, $value);
// e107::getDebug()->log($fieldname.'__'.$key.": ".$value);
} }
return $this; return $this;
} }