danbroooks
danbroooks

Reputation: 2800

Changing the fieldtype of Content in Silverstripe's SiteTree

Is it possible to change the field type for Content in the db from an extension?

It seems I can't override it like so:

class ParsedownExtension extends DataExtension {

    private static $db = array(
        'Content' => 'ParsedownField'
    );
}

My field type & extension does work because it works fine with a fieldname different to Content

Upvotes: 2

Views: 145

Answers (1)

3dgoo
3dgoo

Reputation: 15794

It is possible to change a field type by setting it in your _config.php file.

mysite/_config.php

$fields = Config::inst()->get('SiteTree', 'db', Config::UNINHERITED); 
$fields['Content'] = 'ParsedownField'; 
Config::inst()->update('SiteTree', 'db', $fields);

This answer was found a question on the Silverstripe Forum:
http://www.silverstripe.org/general-questions/show/23967

Upvotes: 1

Related Questions