updating this part and passing 2nd argument to true when making instance of extension it works fine
ok so nothing is now saved on extension, clear.
saving data on owner within extension also fixed the problem
@thezenmonkey has left the channel
Hello folks, I have a class that extends the
File class on which I am trying to hook
onAfterUpload, but without success. Seems like it is just not being called. I am using a normal UploadField with a
has_one relation to my custom File class. Any ideas?
Does it extend File? or is it an
Extension of File? It needs to be the latter
It extends file, but then instead of using the File class I am using the custom one. Should that not work?
@Nik as @gened suggested, you can still subclass
Fileif you really need to, but in order to add custom logic to your own
onAfterUpload() implementation, it will need to be on a
DataEextension subclass that is applied to
Thanks. Wasn't aware there was a difference with custom logic in subclassing vs extending. 👍
The difference in terms of what you can and can't do, comes down to what the framework is permitting. In this case, you can see that
File::onAfterUpload() simply calls
$this->extend() which indicates that extensions can and should hook into it
Having said that, I can't see any reason why if your
File subclass contained its own
onAfterUpload() that it wouldn't also be called, as long as you called
parent::onAfterUpload() in it too.
Never tried myself TBH
Yeah, that was my thought too, even though it calls
$this->extend it would also need to call the function on my subclass. Might need to look into it a bit more. I'll check if I can get it to work with extensions first and then work it out from there
Can anyone explain the difference between various methods of creating an object? e.g:
- new TextField();
@Ben Yes, the first is the standard (language level) way of doing this