Commit c5d0f251 authored by Qiang Xue's avatar Qiang Xue

Fixes #6318: Made widgets more error-tolerant and user-friendly when certain option values are null

parent 23b44e60
...@@ -94,7 +94,7 @@ class Collapse extends Widget ...@@ -94,7 +94,7 @@ class Collapse extends Widget
$items = []; $items = [];
$index = 0; $index = 0;
foreach ($this->items as $item) { foreach ($this->items as $item) {
if (!isset($item['label'])) { if (!array_key_exists('label', $item)) {
throw new InvalidConfigException("The 'label' option is required."); throw new InvalidConfigException("The 'label' option is required.");
} }
$header = $item['label']; $header = $item['label'];
...@@ -116,7 +116,7 @@ class Collapse extends Widget ...@@ -116,7 +116,7 @@ class Collapse extends Widget
*/ */
public function renderItem($header, $item, $index) public function renderItem($header, $item, $index)
{ {
if (isset($item['content'])) { if (array_key_exists('content', $item)) {
$id = $this->options['id'] . '-collapse' . $index; $id = $this->options['id'] . '-collapse' . $index;
$options = ArrayHelper::getValue($item, 'contentOptions', []); $options = ArrayHelper::getValue($item, 'contentOptions', []);
$options['id'] = $id; $options['id'] = $id;
......
...@@ -84,7 +84,7 @@ class Dropdown extends Widget ...@@ -84,7 +84,7 @@ class Dropdown extends Widget
$lines[] = $item; $lines[] = $item;
continue; continue;
} }
if (!isset($item['label'])) { if (!array_key_exists('label', $item)) {
throw new InvalidConfigException("The 'label' option is required."); throw new InvalidConfigException("The 'label' option is required.");
} }
$encodeLabel = isset($item['encode']) ? $item['encode'] : $this->encodeLabels; $encodeLabel = isset($item['encode']) ? $item['encode'] : $this->encodeLabels;
......
...@@ -142,7 +142,7 @@ class Tabs extends Widget ...@@ -142,7 +142,7 @@ class Tabs extends Widget
} }
foreach ($this->items as $n => $item) { foreach ($this->items as $n => $item) {
if (!isset($item['label'])) { if (!array_key_exists('label', $item)) {
throw new InvalidConfigException("The 'label' option is required."); throw new InvalidConfigException("The 'label' option is required.");
} }
$encodeLabel = isset($item['encode']) ? $item['encode'] : $this->encodeLabels; $encodeLabel = isset($item['encode']) ? $item['encode'] : $this->encodeLabels;
...@@ -216,7 +216,7 @@ class Tabs extends Widget ...@@ -216,7 +216,7 @@ class Tabs extends Widget
if (is_string($item)) { if (is_string($item)) {
continue; continue;
} }
if (!isset($item['content'])) { if (!array_key_exists('content', $item)) {
throw new InvalidConfigException("The 'content' option is required."); throw new InvalidConfigException("The 'content' option is required.");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment