PHP code example of silvercommerce / versionhistoryfield

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

    

silvercommerce / versionhistoryfield example snippets


class YourDataObject extends DataObject
{
    ...

    public function getCMSFields()
    {
        $fields = parent::getCMSFields();

        $fields->addFieldToTab(
            "Root.History",
            VersionHistoryField::create(
                "History",
                _t("SilverCommerce\VersionHistoryField.History", "History"),
                $this
            )->addExtraClass("stacked") // make the field full width
        );

        return $fields;
    }

    ...
}