Last active
July 5, 2024 15:28
-
-
Save tiller1010/b1622a1a1634125f550a8cdf052f04cb to your computer and use it in GitHub Desktop.
Replaces a SilverStripe Fieldlist with a tabset in a DataExtension
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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