--- /dev/null
+{include file="shared_multipleSelectionFormField"}
+
+{if $field->getVisibleEverywhereFieldId() !== null}
+ <script data-relocate="true">
+ const label = document.querySelector('label[for="{$field->getPrefixedId()}"]');
+
+ document.querySelectorAll('input[name="{$field->getVisibleEverywhereFieldId()}"]').forEach((input) => {
+ input.addEventListener("change", () => {
+ setLabelText(input.value);
+ });
+ });
+
+ function setLabelText (value) {
+ label.innerHTML = parseInt(value) === 0 ? '{unsafe:$field->getLabel()|encodeJS}' : '{unsafe:$field->getInvertedLabel()|encodeJS}';
+ }
+
+ setLabelText(document.querySelector('input[name="{$field->getVisibleEverywhereFieldId()}"]:checked').value);
+ </script>
+{/if}
--- /dev/null
+<?php
+
+namespace wcf\system\form\builder\field;
+
+use wcf\data\page\PageNodeTree;
+use wcf\system\WCF;
+
+/**
+ * Implementation of a form field for selecting multiple pages.
+ *
+ * @author Olaf Braun
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.2
+ */
+final class PagesFormField extends MultipleSelectionFormField
+{
+ use TDefaultIdFormField;
+
+ /**
+ * @inheritDoc
+ */
+ protected $templateName = 'shared_multiplePagesSelectionFormField';
+
+ private ?string $visibleEverywhereFieldId = null;
+ private string $invertedLabel = '';
+
+ public function __construct()
+ {
+ $this
+ ->options((new PageNodeTree())->getNodeList(), true)
+ ->filterable();
+ }
+
+ #[\Override]
+ protected static function getDefaultId()
+ {
+ return 'pageIDs';
+ }
+
+ public function getVisibleEverywhereFieldId(): ?string
+ {
+ return $this->visibleEverywhereFieldId;
+ }
+
+ public function visibleEverywhereFieldId(?string $visibleEverywhereFieldId): self
+ {
+ $this->visibleEverywhereFieldId = $visibleEverywhereFieldId;
+
+ return $this;
+ }
+
+ public function getInvertedLabel(): string
+ {
+ return $this->invertedLabel;
+ }
+
+ public function invertedLabel(string $languageItem, array $variables = []): self
+ {
+ $this->invertedLabel = WCF::getLanguage()->getDynamicVariable($languageItem, $variables);
+
+ return $this;
+ }
+}