Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Dataextension - change db field type


Go to End


2 Posts   1014 Views

Avatar
JonShutt

Community Member, 244 Posts

14 June 2013 at 10:56am

I have a dataextension that adds fields to the database, all fine, but I also want to change an existing field Title, from varchar, to text, but it doesn't seem to pick this change up, and leaves it as a varchar

class EditableFormFieldDecorator extends DataExtension {
    static $db = array (
        "Title" => "Text",
        "ParentClass" => "Varchar"
    );

Is there anyway of overriding the field type? I really don't want to edit the core files...

Avatar
JonShutt

Community Member, 244 Posts

14 June 2013 at 11:42am

OK, i found a way

instead of trying to change the field type in the in the DataExtension function, I update the db fields in the _config.php file:

$fields = Config::inst()->get('EditableFormField', 'db', Config::UNINHERITED);
$fields['Title'] = 'Text';
Config::inst()->update('EditableFormField', 'db', $fields);