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.

General Questions

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

Dataextension - change db field type


2 Posts   326 Views


14 June 2013 at 10:56am Community Member, 233 Posts

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


14 June 2013 at 11:42am Community Member, 233 Posts

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