So from what I read, are extensions usually only used to extend a single class while traits can be used to add functionality to multiple classes?
Cool thanks for clearing that up @null 🙂
Right and it seems like DataExtensions can be used to introduce new methods without having to actually change the code of the class you’re modifying through the config layer? While traits, you need to use a
use statement in the class you’re changing? Is that correct?
Hey, just wanted to ask if anyone could explain the use case/differences between using Traits and Extensions in SilverStripe? 🙂 They seem to do similar things, but I’m pretty sure they’re different (just not sure how) 😅
Its not too bad, issue is its syntax is more verbose than some of the other languages, meaning you have to type more code
@StefanO I remember doing something similar but can’t remember the correct syntax. i think it was something along the lines of
Example of adding fields to the Member object: https://docs.silverstripe.org/en/4/developer_guides/extending/extensions/
Did you want the Member class to be separate from the ExtendedMember class?
@StefanO Did you use a data extension to extend the member class?
Hello, in SearchForm in the CMS, is there a way I can override $classesToSearch? Would a DataExtension or Injector be the way to go?