1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-02 20:57:26 +02:00

Custom Tab Label for Custom Fields Form.

This commit is contained in:
Cameron
2017-01-31 09:37:08 -08:00
parent ef543ee370
commit b7d701917f
2 changed files with 42 additions and 8 deletions

View File

@@ -73,7 +73,8 @@ class page_admin extends e_admin_dispatcher
protected $adminMenuAliases = array( protected $adminMenuAliases = array(
'page/edit' => 'page/list', 'page/edit' => 'page/list',
'menu/edit' => 'menu/create' 'menu/edit' => 'menu/create',
'cat/edit' => 'cat/list'
); );
protected $menuTitle = ADLAN_42; protected $menuTitle = ADLAN_42;
@@ -190,7 +191,7 @@ class page_chapters_ui extends e_admin_ui
function init() function init()
{ {
$this->addTitle(CUSLAN_63);
// e107::getMessage()->addWarning("Experimental: Custom Fields"); // e107::getMessage()->addWarning("Experimental: Custom Fields");
$this->tabs = array(LAN_GENERAL,"Custom Fields"); $this->tabs = array(LAN_GENERAL,"Custom Fields");
$this->fields['chapter_fields'] = array('title'=>"Fields", 'tab'=>1, 'type'=>'method', 'data'=>'json', 'writeParms'=>array('nolabel'=>2)); $this->fields['chapter_fields'] = array('title'=>"Fields", 'tab'=>1, 'type'=>'method', 'data'=>'json', 'writeParms'=>array('nolabel'=>2));
@@ -764,7 +765,7 @@ class page_admin_ui extends e_admin_ui
$elid = 'core-page-create'; $elid = 'core-page-create';
$model = $this->getModel(); $model = $this->getModel();
$tabId = 'additional'; $tabId = e107::getCustomFields()->getTabId();
$data = array( $data = array(
'tabs' => $this->getTabs(), 'tabs' => $this->getTabs(),
@@ -799,9 +800,6 @@ class page_admin_ui extends e_admin_ui
*/ */
private function initCustomFields($chap=null) private function initCustomFields($chap=null)
{ {
$tabId = 'additional';
e107::getCustomFields()->setTab($tabId, "Additional");
if(!empty($this->chapterFields[$chap])) if(!empty($this->chapterFields[$chap]))
{ {
@@ -809,6 +807,7 @@ class page_admin_ui extends e_admin_ui
} }
else else
{ {
$tabId = e107::getCustomFields()->getTabId();
e107::css('inline', '.nav-tabs li a[href="#tab' . $tabId . '"] { display: none; }'); e107::css('inline', '.nav-tabs li a[href="#tab' . $tabId . '"] { display: none; }');
} }

View File

@@ -24,12 +24,15 @@
private $_field_limit = 20; private $_field_limit = 20;
private $_tab = array('additional'=>'Additional FieldsXX'); private $_tab = array();
private $_tab_default = 'additional';
function __construct() function __construct()
{ {
asort($this->_fieldTypes); asort($this->_fieldTypes);
$this->_tab = array($this->_tab_default => "Additional");
} }
@@ -39,6 +42,16 @@
return $this->_fieldTypes; return $this->_fieldTypes;
} }
public function getTabId()
{
return $this->_tab_default;
}
public function getTabLabel()
{
return $this->_tab[$this->_tab_default];
}
/** /**
* Load the configuration for all custom fields * Load the configuration for all custom fields
@@ -62,6 +75,13 @@
if($arr = $tp->isJSON($data)) if($arr = $tp->isJSON($data))
{ {
if(!empty($arr['__tabs__']))
{
$this->_tab = $arr['__tabs__'];
unset($arr['__tabs__']);
}
$this->_config = $arr; $this->_config = $arr;
} }
@@ -239,7 +259,11 @@
} }
$text = "<table class='table table-striped table-bordered'> $text = "
<div class='form-group'>
".$frm->text('__e_customfields_tabs__', $this->_tab[$this->_tab_default], 30, array('placeholder'=>"Tab label",'size'=>'medium', 'required'=>1))."
</div>
<table class='table table-striped table-bordered'>
<colgroup> <colgroup>
<col /> <col />
<col /> <col />
@@ -397,8 +421,19 @@
$new = array(); $new = array();
if(!empty($postData['__e_customfields_tabs__']))
{
$new['__tabs__'] = array($this->_tab_default => $postData['__e_customfields_tabs__']);
unset($postData['__e_customfields_tabs__']);
}
foreach($postData[$fieldname] as $fields) foreach($postData[$fieldname] as $fields)
{ {
if(empty($fields['key']) || empty($fields['type'])) if(empty($fields['key']) || empty($fields['type']))
{ {
continue; continue;