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.

All other Modules

Discuss all other Modules here.

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

Userforms (ss3.0) > Extending a Field Type


3 Posts   450 Views


12 June 2013 at 10:24am Community Member, 233 Posts

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.


15 June 2013 at 8:19pm Forum Moderator, 5511 Posts

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


17 June 2013 at 11:17am Community Member, 233 Posts

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