public function edit($content, $newRow = false)
    {
        // if no current repeater id, reserve next new repeater id for use on save
        $repeaterId = $content ?: PageBlockRepeaterRows::nextFreeRepeaterId();
        $this->_editViewData['renderedRows'] = '';
        $this->_editViewData['itemName'] = '';
        $this->_editViewData['maxRows'] = '';

        if ($repeaterBlocks = BlockRepeater::getRepeaterBlocks($this->_block->id)) {
            $blockRepeater = BlockRepeater::preload($this->_block->id);
            $this->_editViewData['itemName'] = $blockRepeater->item_name;
            $this->_editViewData['maxRows'] = $blockRepeater->max_rows;
            // check if new or existing row needs displaying
            if ($newRow) {
                $renderedRow = '';
                $repeaterRowId = PageBlockRepeaterRows::nextFreeRepeaterRowId($repeaterId);
                foreach ($repeaterBlocks as $repeaterBlock) {
                    $renderedRow .= $repeaterBlock->setPageId($this->_block->getPageId())->setRepeaterData($repeaterId, $repeaterRowId)->getTypeObject()->edit('');
                }
                return (string) CmsBlockInput::make('repeater.row', ['repeater_id' => $repeaterId, 'row_id' => $repeaterRowId, 'blocks' => $renderedRow]);
            } else {
                $repeaterRowsData = PageBlockRepeaterData::loadRepeaterData($repeaterId, $this->_block->getVersionId());
                foreach ($repeaterRowsData as $repeaterRowId => $repeaterRowData) {
                    $renderedRow = '';
                    foreach ($repeaterBlocks as $repeaterBlockId => $repeaterBlock) {
                        $fieldContent = isset($repeaterRowData[$repeaterBlockId]) ? $repeaterRowData[$repeaterBlockId] : '';
                        $renderedRow .= $repeaterBlock->setPageId($this->_block->getPageId())->setRepeaterData($repeaterId, $repeaterRowId)->getTypeObject()->edit($fieldContent);
                    }
                    $this->_editViewData['renderedRows'] .= CmsBlockInput::make('repeater.row', ['repeater_id' => $repeaterId, 'row_id' => $repeaterRowId, 'blocks' => $renderedRow]);
                }
            }
        }

        $this->_editViewData['_repeaterId'] = $this->_block->getRepeaterId();
        $this->_editViewData['_repeaterRowId'] = $this->_block->getRepeaterRowId();

        return parent::edit($repeaterId);
    }
public function edit($content, $newRow = false)
    {
        // if no current repeater id, reserve next new repeater id for use on save
        $repeaterId = $content ?: PageBlockRepeaterRows::nextFreeRepeaterId();
        $this->_editViewData['renderedRows'] = '';
        $this->_editViewData['itemName'] = '';
        $this->_editViewData['maxRows'] = '';

        if ($repeaterBlocks = BlockRepeater::getRepeaterBlocks($this->_block->id)) {
            $blockRepeater = BlockRepeater::preload($this->_block->id);
            $this->_editViewData['itemName'] = $blockRepeater->item_name;
            $this->_editViewData['maxRows'] = $blockRepeater->max_rows;
            // check if new or existing row needs displaying
            if ($newRow) {
                $renderedRow = '';
                $repeaterRowId = PageBlockRepeaterRows::nextFreeRepeaterRowId($repeaterId);
                foreach ($repeaterBlocks as $repeaterBlock) {
                    $renderedRow .= $repeaterBlock->setPageId($this->_block->getPageId())->setRepeaterData($repeaterId, $repeaterRowId)->getTypeObject()->edit('');
                }
                return (string) CmsBlockInput::make('repeater.row', ['repeater_id' => $repeaterId, 'row_id' => $repeaterRowId, 'blocks' => $renderedRow]);
            } else {
                $repeaterRowsData = PageBlockRepeaterData::loadRepeaterData($repeaterId, $this->_block->getVersionId());
                foreach ($repeaterRowsData as $repeaterRowId => $repeaterRowData) {
                    $renderedRow = '';
                    foreach ($repeaterBlocks as $repeaterBlockId => $repeaterBlock) {
                        $fieldContent = isset($repeaterRowData[$repeaterBlockId]) ? $repeaterRowData[$repeaterBlockId] : '';
                        $renderedRow .= $repeaterBlock->setPageId($this->_block->getPageId())->setRepeaterData($repeaterId, $repeaterRowId)->getTypeObject()->edit($fieldContent);
                    }
                    $this->_editViewData['renderedRows'] .= CmsBlockInput::make('repeater.row', ['repeater_id' => $repeaterId, 'row_id' => $repeaterRowId, 'blocks' => $renderedRow]);
                }
            }
        }

        $this->_editViewData['_repeaterId'] = $this->_block->getRepeaterId();
        $this->_editViewData['_repeaterRowId'] = $this->_block->getRepeaterRowId();

        return parent::edit($repeaterId);
    }
public function edit ( $ content , $ newRow = false ) { // if no current repeater id, reserve next new repeater id for use on save
 $ repeaterId = $ content ? : PageBlockRepeaterRows :: nextFreeRepeaterId ( ) ; $ this -> _editViewData [ 'renderedRows' ] = '' ; $ this -> _editViewData [ 'itemName' ] = '' ; $ this -> _editViewData [ 'maxRows' ] = '' ; if ( $ repeaterBlocks = BlockRepeater :: getRepeaterBlocks ( $ this -> _block -> id ) ) { $ blockRepeater = BlockRepeater :: preload ( $ this -> _block -> id ) ; $ this -> _editViewData [ 'itemName' ] = $ blockRepeater -> item_name ; $ this -> _editViewData [ 'maxRows' ] = $ blockRepeater -> max_rows ; // check if new or existing row needs displaying
 if ( $ newRow ) { $ renderedRow = '' ; $ repeaterRowId = PageBlockRepeaterRows :: nextFreeRepeaterRowId ( $ repeaterId ) ; foreach ( $ repeaterBlocks as $ repeaterBlock ) { $ renderedRow .= $ repeaterBlock -> setPageId ( $ this -> _block -> getPageId ( ) ) -> setRepeaterData ( $ repeaterId , $ repeaterRowId ) -> getTypeObject ( ) -> edit ( '' ) ; } return ( string ) CmsBlockInput :: make ( 'repeater.row' , [ 'repeater_id' => $ repeaterId , 'row_id' => $ repeaterRowId , 'blocks' => $ renderedRow ] ) ; } else { $ repeaterRowsData = PageBlockRepeaterData :: loadRepeaterData ( $ repeaterId , $ this -> _block -> getVersionId ( ) ) ; foreach ( $ repeaterRowsData as $ repeaterRowId => $ repeaterRowData ) { $ renderedRow = '' ; foreach ( $ repeaterBlocks as $ repeaterBlockId => $ repeaterBlock ) { $ fieldContent = isset ( $ repeaterRowData [ $ repeaterBlockId ] ) ? $ repeaterRowData [ $ repeaterBlockId ] : '' ; $ renderedRow .= $ repeaterBlock -> setPageId ( $ this -> _block -> getPageId ( ) ) -> setRepeaterData ( $ repeaterId , $ repeaterRowId ) -> getTypeObject ( ) -> edit ( $ fieldContent ) ; } $ this -> _editViewData [ 'renderedRows' ] .= CmsBlockInput :: make ( 'repeater.row' , [ 'repeater_id' => $ repeaterId , 'row_id' => $ repeaterRowId , 'blocks' => $ renderedRow ] ) ; } } } $ this -> _editViewData [ '_repeaterId' ] = $ this -> _block -> getRepeaterId ( ) ; $ this -> _editViewData [ '_repeaterRowId' ] = $ this -> _block -> getRepeaterRowId ( ) ; return parent :: edit ( $ repeaterId ) ; }
Admin view for editing repeater data
Can return an individual repeater row with default block data)
@param string $content
@param bool $newRow
@return string
Admin view for editing repeater data Can return an individual repeater row with default block data )