Hi all,
I have been working on a Front End Editing module and made use of Object::useCustomClass to wrap the default HTMLText and Varchar forTemplate methods to inject some custom elements around values to enable all the magic.
I now want to be able to do the same with Image objects, but I am unable to override the forTemplate method....
This is a simplified version of what I have:
FrontEndImage.php
class FrontEndImage extends Image {
public function forTemplate() {
$value = parent::forTemplate();
return "<span class='editable'>" . $value . "</span>";
}
}
_config.php
Object::useCustomClass('Image', 'FrontEndImage', true);
// I have also tried Object::useCustomClass('Image', 'FrontEndImage');
My FrontEndImage class is never initiated and the forTemplate method on my class is never called.
I have tried adding breakpoints and stepping through Silverstripe and it seems it ignores my useCustomClass and uses the Image class directly.
So my questions are
- Is there some limitation with useCustomClass on has_one and has_many realtions?
- Or is this a bug?
- Or am I missing something?
Any input would be appreciated!
Cheers