Skip to content

Instantly share code, notes, and snippets.

@tiller1010
Last active July 5, 2024 15:28
Show Gist options
  • Select an option

  • Save tiller1010/b1622a1a1634125f550a8cdf052f04cb to your computer and use it in GitHub Desktop.

Select an option

Save tiller1010/b1622a1a1634125f550a8cdf052f04cb to your computer and use it in GitHub Desktop.
Replaces a SilverStripe Fieldlist with a tabset in a DataExtension
<?php
/* Capture original fields by value */
$orignalFields = FieldList::create($fields->toArray());
/* Remove all original fields to prevent conflicts with replacement */
$fields->each(function($field) use (&$fields) {
$fields->remove($field);
});
/* Insert new tabs */
$fields->push(
new TabSet(
'Root',
new Tab('Main'),
new Tab('New tab', $newTabFields)
)
);
/* Restore original fields */
$fields->addFieldsToTab('Root.Main', $orignalFields);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment