PHP code example of xini / silverstripe-matrixfieldgroup

1. Go to this page and download the library: Download xini/silverstripe-matrixfieldgroup 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/ */

    

xini / silverstripe-matrixfieldgroup example snippets


$matrixfield = MatrixFieldGroup::create("Finances")
	->setColumnHeaders(array(
		"Account",
		"Debit",
		"Credit"
	));
	
$objects = SomeObject::get();

foreach ($objects as $object) {
	// add row for each object
	$catalogueFields->addRow(
		$object->Title,
		NumericField::create('Debit['.$object->ID.']', $object->Title.': Debit')
			->addExtraClass('hiddenLabel'),
		NumericField::create('Credit['.$object->ID.']', $object->Title.': Credit')
			->addExtraClass('hiddenLabel')
	);
}