diff --git a/src/ConfigPagesForm.php b/src/ConfigPagesForm.php index c1bc881..99d1b89 100644 --- a/src/ConfigPagesForm.php +++ b/src/ConfigPagesForm.php @@ -154,15 +154,6 @@ class ConfigPagesForm extends ContentEntityForm { ->getStorage('config_pages') ->loadByProperties($conditions); - // Show context message. - $show_warning = $config_pages_type->context['show_warning']; - $label = $config_pages_type->getContextLabel(); - if (!empty($label) && $show_warning) { - $this->messenger->addWarning($this->t('Please note that this Page is context sensitive, current context is %label', [ - '%label' => $label, - ])); - } - if ($this->operation == 'edit') { $form['#title'] = $this->t('Edit custom config page %label', ['%label' => $config_pages->label()]); } @@ -173,10 +164,11 @@ class ConfigPagesForm extends ContentEntityForm { // Create form elements to select another context. $links = $config_pages_type->getContextLinks(); + $count_context_links = 0; foreach ($links as $group_id => $context_links) { // If no contextual links provided then just don't show fieldset. - if (!count($context_links)) { + if (count($context_links) <= 1) { continue; } @@ -198,9 +190,19 @@ class ConfigPagesForm extends ContentEntityForm { '#title' => $link['title'], '#prefix' => ($pos > 0) ? ' | ' : '', ]; + $count_context_links++; } } + // Show context message. + $show_warning = $config_pages_type->context['show_warning']; + $label = $config_pages_type->getContextLabel(); + if (!empty($label) && $show_warning && $count_context_links > 1) { + $this->messenger->addWarning($this->t('Please note that this Page is context sensitive, current context is %label', [ + '%label' => $label, + ])); + } + // Add context import fieldset if any CP exists at this moment. if (!$this->entity->get('context')->isEmpty()) { $options = [];