Ryan M Ryan M - 5 months ago 31
PHP Question

Overload Enum in SilverStripe DataExtension

Is it possible to overload an Enum field using a DataExtension?

class Order extends DataObject {
private static $db=array('Status'=>"Enum('Unpaid, Paid','Unpaid')";
}

class OrderExtension extends DataExtension {
private static $db=array('Status'=>"Enum('Unpaid, Paid, Cancelled','Unpaid')"; //doesn't work
}

Answer

I couldn't figure out how to get the augmentDatabase() method to work, but after speaking with a colleague he suggested using config.yml and this did the trick.

Order:
    db:
        Status: Enum('Unpaid, Paid, Cancelled','Unpaid')
Comments