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.
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:
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.