Some articles are very long and getting cut off when saved to the database.

Is it possible to define a 'richtext' fieldtype as 'MEDIUMTEXT', or would I have to write a plugin to replicate the 'richtext' fieldtype with a different field attribute defined in defineContentAttribute? Any other considerations to take into account? Such as search, indexing, redactor or otherwise?

Part 2 of this question would be: what is the simplest way to duplicate the RichTextField in a plugin? Can I just extend 'RichTextFieldType' and redefine getName and defineContentAttribute? I tried the following with no luck.

Update: This creates a 'Rich Text (Medium)' field with the correct DB column type of 'MEDIUMTEXT', but causes the 'Edit Entry' screen in the CP to be blank below the entry title (silent fail?); and if switching to entry type with this field getting a garnish error 'Double-instantiating a transparent text input on an element'.

class LongTextFields_MediumRichTextFieldType extends RichTextFieldType
    public function getName()
        return Craft::t('Rich Text (Medium)');
    public function defineContentAttribute()
        return array(AttributeType::String, 'column' => ColumnType::MediumText);

Another option might be to just redefine the columntype manually in the database. Is there any chance this value will ever get overwritten? (i.e. upgrades, migrations, etc).

1 Answer 1


Defining your a plugin with it's own field type that extends RichTextFieldType might work (haven't tested), but your current code is slightly off.

The field type class/file name needs to be PluginHandle_FieldTypeNameFieldType before Craft will even recognize it.

Also, the ColumnType enum uses MediumText, not Mediumtext.

Really, what we should probably do is make this a setting on the field type because it does pop up every so often and there currently isn't a clean answer.

  • Thanks for noticing the pluginHandle issue. This helps, but the field silently fails when trying to render the 'Edit Entry' page. And getting a weird garnish error when switching to entry type with this field 'Double-instantiating a transparent text input on an element.' +1 for adding as setting. Oct 26, 2014 at 16:17
  • Yeah, I thought there might be some JavaScript coupled to the RTE class. I'll see what we can do about a setting.
    – Brad Bell
    Oct 26, 2014 at 16:18
  • In the meantime, do you think it would be safe to change the column type in the database directly. Any reason that would ever get overwritten by craft? Doesn't matter now while in dev, but would be pretty disastrous once the site gets populated. Oct 28, 2014 at 1:31
  • As far as hacking the db schema goes, it's probably a relatively safe change. But if some update comes down the road, breaks it and you email support, we're just going to tell you that you shouldn't have hacked the schema. ;) Probably worth doing a test locally to make sure there are places in the code we're not assuming a ColumnType::Text, too.
    – Brad Bell
    Oct 28, 2014 at 2:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.