From e4a3d3511960a4e4706c62e6efe0af9ae0c0e5cc Mon Sep 17 00:00:00 2001 From: Nikolas Grottendieck Date: Mon, 11 Jul 2016 22:00:23 +0200 Subject: [PATCH] Allow URLs to be used instead of content for Tab Widget Dropdown items Fixes #113 --- Tabs.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Tabs.php b/Tabs.php index 3044f11..e671184 100644 --- a/Tabs.php +++ b/Tabs.php @@ -44,6 +44,10 @@ use yii\helpers\ArrayHelper; * 'label' => 'DropdownB', * 'content' => 'DropdownB, Anim pariatur cliche...', * ], + * [ + * 'label' => 'External Link', + * 'url' => 'http://www.example.com', + * ], * ], * ], * ], @@ -240,8 +244,11 @@ class Tabs extends Widget if (isset($item['visible']) && !$item['visible']) { continue; } - if (!array_key_exists('content', $item)) { - throw new InvalidConfigException("The 'content' option is required."); + if (!(array_key_exists('content', $item) xor array_key_exists('url', $item))) { + throw new InvalidConfigException("Either the 'content' or the 'url' option is required."); + } + if (array_key_exists('url', $item)) { + continue; } $content = ArrayHelper::remove($item, 'content');