diff --git a/wire/modules/Fieldtype/FieldtypeRepeater/FieldtypeRepeater.module b/wire/modules/Fieldtype/FieldtypeRepeater/FieldtypeRepeater.module index a4bc96df..984d2775 100644 --- a/wire/modules/Fieldtype/FieldtypeRepeater/FieldtypeRepeater.module +++ b/wire/modules/Fieldtype/FieldtypeRepeater/FieldtypeRepeater.module @@ -355,13 +355,19 @@ class FieldtypeRepeater extends Fieldtype implements ConfigurableModule { // check for nested repeater foreach($repeaters as $name) { $repeaterItems = $ownerPage->get($name); - if(!$repeaterItems || !$repeaterItems instanceof PageArray) continue; - foreach($repeaterItems as $nestedOwnerPage) { - // perform recursive check - $hasField = $this->isRepeaterItemValidOnPage($repeaterItem, $nestedOwnerPage); - if($hasField) break; + if(!$repeaterItems) continue; + if($repeaterItems instanceof PageArray) { + foreach($repeaterItems as $nestedOwnerPage) { + // perform recursive check + $hasField = $this->isRepeaterItemValidOnPage($repeaterItem, $nestedOwnerPage); + if($hasField) break; + } + } else if($repeaterItems instanceof RepeaterPage) { + // for single item value (i.e. FieldtypeFieldsetPage) + $hasField = $this->isRepeaterItemValidOnPage($repeaterItem, $repeaterItems); + } else { + continue; } - if($hasField) break; } return $hasField; @@ -1321,6 +1327,14 @@ class FieldtypeRepeater extends Fieldtype implements ConfigurableModule { if(!$page->id || !$field->id) return false; $value = $page->get($field->name); + + if($value instanceof RepeaterPage) { + // for FieldsetPage compatibility + $pageArray = $this->getBlankValue($page, $field); + $pageArray->add($value); + $pageArray->resetTrackChanges(); + $value = $pageArray; + } // pages that will be saved $savePages = array(); diff --git a/wire/modules/Fieldtype/FieldtypeRepeater/InputfieldRepeater.css b/wire/modules/Fieldtype/FieldtypeRepeater/InputfieldRepeater.css index 9c7f4bd3..e96411d0 100644 --- a/wire/modules/Fieldtype/FieldtypeRepeater/InputfieldRepeater.css +++ b/wire/modules/Fieldtype/FieldtypeRepeater/InputfieldRepeater.css @@ -61,6 +61,12 @@ display: none; } .Inputfields .InputfieldRepeater .InputfieldRepeaterDelete { display: none; } +.Inputfields .InputfieldRepeater.InputfieldRepeaterSingle > .InputfieldContent > .Inputfields { + margin-bottom: 0; } + .Inputfields .InputfieldRepeater.InputfieldRepeaterSingle > .InputfieldContent > .Inputfields > .InputfieldRepeaterItem { + margin-bottom: 0; } + .Inputfields .InputfieldRepeater.InputfieldRepeaterSingle > .InputfieldContent > .Inputfields > .InputfieldRepeaterItem > .InputfieldHeader { + display: none; } .InputfieldRepeater .InputfieldWrapper, .InputfieldRepeater .InputfieldWrapper > .Inputfields { diff --git a/wire/modules/Fieldtype/FieldtypeRepeater/InputfieldRepeater.module b/wire/modules/Fieldtype/FieldtypeRepeater/InputfieldRepeater.module index 76780404..39f7041c 100644 --- a/wire/modules/Fieldtype/FieldtypeRepeater/InputfieldRepeater.module +++ b/wire/modules/Fieldtype/FieldtypeRepeater/InputfieldRepeater.module @@ -579,16 +579,22 @@ class InputfieldRepeater extends Inputfield implements InputfieldItemList { $this->wire('modules')->get('JqueryUI')->use('vex'); $this->preloadInputfieldAssets(); + $min = (int) $this->repeaterMinItems; + $max = (int) $this->repeaterMaxItems; + if($this->field->get('repeaterLoading') == FieldtypeRepeater::loadingOff) { $this->addClass('InputfieldRepeaterNoAjaxAdd', 'wrapClass'); } - if($this->repeaterMaxItems > 0) { + if($max > 0) { $this->addClass('InputfieldRepeaterMax', 'wrapClass'); } - if($this->repeaterMinItems > 0) { + if($min > 0) { $this->addClass('InputfieldRepeaterMin', 'wrapClass'); } - if($this->repeaterDepth > 0) { + if($min === 1 && $max === 1) { + $this->addClass('InputfieldRepeaterSingle', 'wrapClass'); + + } else if($this->repeaterDepth > 0) { $this->addClass('InputfieldRepeaterDepth', 'wrapClass'); } if($this->accordionMode) { diff --git a/wire/modules/Fieldtype/FieldtypeRepeater/InputfieldRepeater.scss b/wire/modules/Fieldtype/FieldtypeRepeater/InputfieldRepeater.scss index ac9c6528..0215538f 100644 --- a/wire/modules/Fieldtype/FieldtypeRepeater/InputfieldRepeater.scss +++ b/wire/modules/Fieldtype/FieldtypeRepeater/InputfieldRepeater.scss @@ -110,6 +110,19 @@ // delete checkbox display: none; } + + &.InputfieldRepeaterSingle { + // repeater in single-item mode + > .InputfieldContent > .Inputfields { + margin-bottom: 0; + > .InputfieldRepeaterItem { + margin-bottom: 0; + > .InputfieldHeader { + display: none; + } + } + } + } }