tiller1010
tiller1010

Reputation: 131

How to customize components in the admin area of SilverStripe?

I am trying to follow along with this tutorial.

The problem is that the Injector API is slightly different than how it is used in the tutorial. Injector does not need to be imported, and many of the methods are found under certain properties (such as Injector.default.transform and Injector.default.component.transform).

I have tried:

Injector.default.component.transform('character-count-transform', (updater) => { updater('TextField', CharacterCounter); });

I get no errors in the console, but the TextField is unchanged.

The injector repository even mentions that only some of the documentation will apply to this version.

Upvotes: 1

Views: 101

Answers (1)

cwchong
cwchong

Reputation: 31

The code in the tutorial is correct

Injector.transform('character-count-transform', (updater) => {
  updater.component('TextField', CharacterCounter);
});

But if you are looking at a TextField in Pages admin, you will not see the react component as that section isn't "reactified" yet. Look in Files admin (upload a file) and look at the details form of an image, the text fields should have the updated component rendered. Am still figuring out how to get it to work in the Page admin section, but my initial guess would be to subclass TextField and provide some react-y stuff in that class. dnadesign/silverstripe-elemental for some ideas

Upvotes: 3

Related Questions