/** * @group Ui */ public function testTabs() { $tabOneConfiguration = ['type' => 'tab', 'label' => 'Tab One', 'id' => 'tabOne', 'group' => 'ExampleTab', 'position' => 100, 'contents' => [['id' => 'contentId', 'enable' => true, 'content' => 'The Content of Tab One'], ['id' => 'contentTwoId', 'enable' => true, 'content' => 'The Second Content of Tab One'], ['id' => 'contentThreeId', 'enable' => true, 'content' => 'The third Content of Tab One']]]; $tabTwoConfiguration = ['type' => 'tab', 'label' => 'Tab Two', 'id' => 'tabTwo', 'group' => 'ExampleTab', 'contents' => [['id' => 'contentId', 'enable' => true, 'content' => 'The Content of Tab Two'], ['id' => 'contentTwoId', 'enable' => true, 'content' => 'The Second Content of Tab Two'], ['id' => 'contentThreeId', 'enable' => true, 'content' => 'The third Content of Tab Two']]]; $tabThreeConfiguration = ['type' => 'tab', 'label' => 'Tab Three', 'id' => 'tabThree', 'group' => 'ExampleTab', 'contents' => [['id' => 'contentId', 'enable' => true, 'content' => 'The Content of Tab Three'], ['id' => 'contentTwoId', 'enable' => true, 'content' => 'The Second Content of Tab Three'], ['id' => 'contentThreeId', 'enable' => true, 'content' => 'The third Content of Tab Three']]]; $elementRoute = ['view' => ['name' => zbase_tag() . 'test::contents.test.content', 'enable' => true, 'content' => function () use($tabOneConfiguration, $tabTwoConfiguration, $tabThreeConfiguration) { return zbase_ui_tabs([$tabOneConfiguration, $tabTwoConfiguration, $tabThreeConfiguration]); }], 'url' => '/test/ui-tab', 'enable' => true]; zbase_route_init('uiTest', $elementRoute); $this->visit('/test/ui-tab')->see('<a data-toggle="tab" href="#ExampleTabtabOne">Tab One</a>'); }
/** * Process tabs */ protected function _tabs() { $tabSet = $this->_v('tabs', null); /** * If $formTag is TRUE, will create a form on each tabs */ $formTag = $this->_v('form_tab', true); if (!is_null($tabSet) && is_array($tabSet)) { foreach ($tabSet as $tabName => $tab) { if (!is_array($tab)) { continue; } $tab['widgetEntity'] = $this->entity(); $tabObject = zbase_ui($tab); $tabObject->setGroup($this->id() . 'tabs'); // $tabObject->setAttribute('widgetEntity', $this->entity()); $enabled = $tabObject->enabled(); if ($enabled) { if (!empty($tab['elements'])) { $hasFileElement = false; foreach ($tab['elements'] as $elementName => $element) { if (empty($element['id'])) { $element['id'] = $elementName; $element['name'] = $elementName; } if (!empty($element['type']) && $element['type'] == 'file') { $hasFileElement = true; } // var_dump('_tabs: ' . $tabName); $tabObject->addContent($this->_createElement($element, $tabName)); } unset($tab['elements']); } if (empty($formTag)) { $tabObject->setForm(clone $this); /** * Form Configuration in a tab */ if (!empty($tab['formConfiguration'])) { $tabObject->form()->setAttributes($tab['formConfiguration']); } $this->setFormTag(false); } $tabs[$tabName] = $tabObject; } } // foreach ($tabs as $tabName => $tab) // { // $tab = zbase_ui($tab); // if(!is_array($tab)) // { // continue; // } // $tab['group'] = $this->id() . 'tabs'; // if(!empty($tab['elements'])) // { // $hasFileElement = false; // foreach ($tab['elements'] as $elementName => $element) // { // if(empty($element['id'])) // { // $element['id'] = $elementName; // $element['name'] = $elementName; // } // if(!empty($element['type']) && $element['type'] == 'file') // { // $hasFileElement = true; // } // $tab['contents'][] = $this->_createElement($element, $tabName); // } // unset($tab['elements']); // } // if(empty($formTag)) // { // $tab['form'] = clone $this; // /** // * Form Configuration in a tab // */ // if(!empty($tab['formConfiguration'])) // { // $tab['form']->setAttributes($tab['formConfiguration']); // } // $this->setFormTag(false); // } // $tab['widgetEntity'] = $this->entity(); // $tabs[$tabName] = $tab; // } } if (!empty($tabs)) { $this->_tabs = zbase_ui_tabs($tabs); } }