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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

All other Modules /

Discuss all other Modules here.

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

Userforms (ss3.0) > Extending a Field Type

Go to End

3 Posts   1123 Views


Community Member, 244 Posts

12 June 2013 at 10:24am

Hi there,

I'm trying to extend some of the field types in the UserForms module, to add some extra functions, and override some functions.

Eg - EditableLiteralFieldDecorator.php:


class EditableLiteralFieldDecorator extends DataExtension {

    static $db = array (
        "ExtraField" => "Varchar",

// override to use html editor
    public function getFieldConfiguration() {
        return new FieldList(
            new HtmlEditorField("Fields[$this->ID][CustomSettings][Content]", "HTML", 4, 20, $this->getSetting('Content'))

and in the site _config.php file:

Object::add_extension('EditableLiteralField', 'EditableLiteralFieldDecorator');

Dev/build is creating the extra DB fields no problem, but my 'getFieldConfiguration' function isn't being called, the site is just using the 'getFieldConfiguration' function from the core file. Eg, I want my 'getFieldConfiguration' function override the core module 'getFieldConfiguration' function.


Forum Moderator, 5523 Posts

15 June 2013 at 8:19pm

EditableFormField::getFieldConfiguration() doesn't have any extension hooks so you cannot decorate the fields. What you'd need to do is submit a patch to GitHub adding the extension hooks you need.

// EditableFormField::getFieldConfiguration()
$options = new FieldList(

$this->extend('updateFieldConfiguration', $options);

return $options;

Then you can include a updateFieldConfiguration function in your DataExtension


Community Member, 244 Posts

17 June 2013 at 11:17am

Thanks Will,

I've added " $this->extend()" to into the "getFieldConfiguration" function on the "EditableLiteralField" class. Works great.

Seems that different form fields work a bit diferently, when getting the custom fields, and i couldn't see a universal way of adding in the hook for the base EditableFormField class...