PHP code example of silbinarywolf / multirecordfield
1. Go to this page and download the library: Download silbinarywolf/multirecordfield library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
silbinarywolf / multirecordfield example snippets
class Page extends SiteTree {
private static $has_many = array(
'Cells' => 'BasicContent',
);
public function getCMSFields()
{
$fields = parent::getCMSFields();
$editor = MultiRecordField::create('ContentCellEditor', 'Content Cells', $this->Cells());
$fields->addFieldToTab('Root.ContentCells', $editor);
return $fields;
}
}
foreach ($fields->dataFields() as $field) {
if ($field instanceof GridField) {
$fields->replaceField($field->getName(), $field->transform(new MultiRecordTransformation));
}
}