/** * Admin display for the block * @param string $content * @return string */ public function edit($content) { return CmsBlockInput::make($this->_block->type, $this->_editViewData + ['label' => $this->_block->label, 'name' => $this->_getInputHTMLKey(), 'content' => $content, 'note' => $this->_block->note, '_block' => $this->_block]); }
/** * Admin view for editing repeater data * Can return an individual repeater row with default block data) * @param string $content * @param bool $newRow * @return string */ 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'] = ''; if ($repeaterBlocks = BlockRepeater::getRepeaterBlocks($this->_block->id)) { // 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); }