SilverStripe Number Spinner for Version 4: template not found

Hello!
I am trying to fork a GitHub repository of a SilverStripe module to make it work with SS4. The repository for my fork is here:

https://github.com/ssimo3lsuhsc/silverstripe-v4-spinner-field

This is a screenshot of the error I’m getting. I get the error even after I have ?flushed the cache

I suspect that my error is in the line in src/SpinnerField.php that contains renderWith('SpinnerField'). Shouldn’t that map to templates/SilverStripe/SpinnerField/SpinnerField.ss since my class is in the SilverStripe\SpinnerField namespace? Or possibly templates/SilverStripe/Forms/SpinnerField.ss since my class inherits from SilverStripe\Forms\NumericField? You can respond here or submit a pull request. Thank you.

A couple of things:

It’s best not to use SilverStripe as your base namespace, since that will end up getting added to the SilverStripe directory in the vendor directory.

Once you’ve updated the namespace, you’ll want to match the namespace structure to the directory:

return $this->customise($properties)->renderWith('YourName/YourPackage/SpinnerField');

With the template in:

/templates/YourName/YourPackage/SpinnerField.ss

You are incorrect that the package will be added under the vendor/SilverStripe folder. My composer.json has the line

"name": "ssimo3lsuhsc/silverstripe-v4-spinner-field"

This value is the package name. This line—and only this line—determines the structure of the vendor folder. However, it does NOT define a namespace. A namespace is what you declare at the top of PHP files. Did you notice that both my PHP files begin with

<?php namespace SilverStripe\SpinnerField;?

Furthermore, my composer.json has the key
"autoload":{ "psr-4":{ "SilverStripe\\SpinnerField\\":"src/" } }

Can you please point me to where in the documentation you state that the namespace and the package name must be equal?

I figured out what you mean. I have re-namespaced the project. In most cases, the namespace and package name cannot be equal. But it does work as long as SilverStripe is not the base of the namespace.

What I am having trouble with now is this: The field works the first time it is loaded onto a page since its requirements are lazy-loaded at that point. If I save a record or navigate to another record, the SpinnerField customizations are lost. I’m a bit in the dark when it comes to the proper way to reload a subclass of FormField after the admin module makes its AJAX requests.

On first load after a browser refresh:
silverstripe-spinner-field-before-admin-action

After admin action has been taken, such as saving or navigating, it looks like an ordinary text field. Because I am a new user on this forum, I cannot post another screenshot.

Has anybody ever used React specifically to build a subclass of FormField on the admin side? I’m looking around in the documentation, and I don’t see a lot on subclassing FormField for use on Admin pages, but I figure that most of the core Admin functionality is powered by React. But I could be wrong.