Jump to:

23490 Posts in 18996 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Dataextension - change db field type

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

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

Page: 1
Go to End
Author Topic: 316 Views
  • Futureweb
    Avatar
    Community Member
    232 Posts

    Dataextension - change db field type Link to this post

    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...

  • Futureweb
    Avatar
    Community Member
    232 Posts

    Re: Dataextension - change db field type Link to this post

    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);

    316 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.