diff --git a/wire/modules/Fieldtype/FieldtypeRepeater/InputfieldRepeater.module b/wire/modules/Fieldtype/FieldtypeRepeater/InputfieldRepeater.module index b328b124..c33e1a41 100644 --- a/wire/modules/Fieldtype/FieldtypeRepeater/InputfieldRepeater.module +++ b/wire/modules/Fieldtype/FieldtypeRepeater/InputfieldRepeater.module @@ -327,6 +327,7 @@ class InputfieldRepeater extends Inputfield implements InputfieldItemList { $input = $this->wire()->input; $session = $this->wire()->session; $modules = $this->wire()->modules; + $typeStyles = array(); // if it's already been built, then return the cached version if(!is_null($this->form)) return $this->form; @@ -460,6 +461,10 @@ class InputfieldRepeater extends Inputfield implements InputfieldItemList { $wrapIcon = ''; $wrapClasses = array_unique(array('InputfieldRepeaterItem', $this->className() . 'Item', 'InputfieldNoFocus')); $wrap->addClass(implode(' ', $wrapClasses)); + + $itemType = $this->getRepeaterItemType($page); + $itemTypeName = $this->getRepeaterItemTypeName($itemType); + if(!$isPost) { $wrap->entityEncodeLabel = false; $wrapLabel = @@ -470,12 +475,21 @@ class InputfieldRepeater extends Inputfield implements InputfieldItemList { $wrapLabel = str_replace($matches[0], '', $wrapLabel); $wrapIcon = $matches[1]; } + if(strpos($wrapLabel, '#') !== false && preg_match('/#([0-9a-fA-F]{3,})/', $wrapLabel, $matches)) { + // background-color definition + if(strlen($matches[1]) === 3 || strlen($matches[1]) === 6) { + $wrapLabel = str_replace($matches[0], '', $wrapLabel); + $typeStyles[] = + ".Inputfield_$this->name .InputfieldContent " . + ".InputfieldRepeaterItem[data-typeName=$itemTypeName] > .InputfieldHeader " . + "{ background-color: #$matches[1] }"; + } + } + $wrap->label = $wrapLabel; } else { $wrap->label = "$label " . (++$cnt); } - $itemType = $this->getRepeaterItemType($page); - $itemTypeName = $this->getRepeaterItemTypeName($itemType); $wrap->name = "repeater_item_{$page->id}"; $wrap->wrapAttr('data-page', $page->id); $wrap->wrapAttr('data-type', $itemType); @@ -596,6 +610,11 @@ class InputfieldRepeater extends Inputfield implements InputfieldItemList { // cache $this->form = $form; + + if(!$isPost && count($typeStyles)) { + $styles = ""; + $this->wire()->adminTheme->addExtraMarkup('head', $styles); + } return $form; }