1. Go to this page and download the library: Download baumrock/rockmigrations 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/ */
// module needs to be autoload!
public function init() {
$rm = $this->wire->modules->get('RockMigrations');
if($rm) $rm->watch($this);
}
public function migrate() {
bd('Migrating MyModule...');
}
// get YAML instance
$rm->yaml();
// get array from YAML file
$rm->yaml('/path/to/file.yaml');
// save data to file
$rm->yaml('/path/to/file.yaml', ['foo'=>'bar']);
// syntax
$rm->wrapFields($form, $fields, $fieldset);
// usage
$wire->addHookAfter("ProcessPageEdit::buildForm", function($event) {
$form = $event->return;
/** @var RockMigrations $rm */
$rm = $this->wire->modules->get('RockMigrations');
$rm->wrapFields($form, [
'title' => [
// runtime settings for title field
'columnWidth' => 50,
],
// runtime field example
[
'type' => 'markup',
'label' => 'foo',
'value' => 'bar',
'columnWidth' => 50,
],
'other_field_of_this_template',
], [
'label' => 'I am a new fieldset wrapper',
]);
})