From 3598fb113b91d38006599e9b3fe4a08227693581 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Thu, 18 May 2023 09:41:08 -0400 Subject: [PATCH] Fix issue processwire/processwire-issues#1732 --- .../FieldtypeRepeater/InputfieldRepeater.module | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/wire/modules/Fieldtype/FieldtypeRepeater/InputfieldRepeater.module b/wire/modules/Fieldtype/FieldtypeRepeater/InputfieldRepeater.module index d2d4343c..3a8c11ad 100644 --- a/wire/modules/Fieldtype/FieldtypeRepeater/InputfieldRepeater.module +++ b/wire/modules/Fieldtype/FieldtypeRepeater/InputfieldRepeater.module @@ -142,7 +142,8 @@ class InputfieldRepeater extends Inputfield implements InputfieldItemList { $out = ''; $repeaterTitle = $this->field ? $this->field->get('repeaterTitle') : ''; - $colorPrefix = "\rCOLOR\r"; + $colorPrefix = "\tC/O/L/O/R:"; + $hasColorPrefix = false; if($page->id && $repeaterTitle) { // custom repeater titles specified @@ -156,6 +157,7 @@ class InputfieldRepeater extends Inputfield implements InputfieldItemList { if(strpos($repeaterTitle, '#') !== false) { $repeaterTitle = preg_replace('/#([a-f\d]{3,})/i', "$colorPrefix$1", $repeaterTitle); + if(strpos($repeaterTitle, $colorPrefix) !== false) $hasColorPrefix = true; } if(strpos($repeaterTitle, '{') !== false) { @@ -208,8 +210,10 @@ class InputfieldRepeater extends Inputfield implements InputfieldItemList { $sp = html_entity_decode('​', 0, 'UTF-8'); $out = str_replace('#', "#$sp", $out); } - - $out = str_replace($colorPrefix, '#', $out); + + if($hasColorPrefix && strpos($out, $colorPrefix) === strrpos($out, $colorPrefix)) { + $out = str_replace($colorPrefix, '#', $out); + } return $out; } @@ -627,7 +631,12 @@ class InputfieldRepeater extends Inputfield implements InputfieldItemList { if(!$isPost && count($typeStyles)) { $styles = ""; - $this->wire()->adminTheme->addExtraMarkup('head', $styles); + if($this->wire()->config->ajax && ($this->page instanceof RepeaterPage || $this->hasPage instanceof RepeaterPage)) { + // ajax-rendered nested repeater page + $this->prependMarkup .= $styles; + } else { + $this->wire()->adminTheme->addExtraMarkup('head', $styles); + } } return $form;