Skip to content

Commit c83d55d

Browse files
authored
fix: FieldServiceProvider not registering assets with Nova (#4) (#9)
* fix: use standard Nova::serving() pattern for asset registration The previous $app->resolving() pattern was not correctly registering the JavaScript assets with Nova, causing the Vue components to never be loaded in the browser. Switched to the standard Nova asset registration pattern: - Import Laravel\Nova\Events\ServingNova - Use Nova::serving() directly in boot() * docs: update changelog and version for v1.0.10
1 parent 9029da0 commit c83d55d

4 files changed

Lines changed: 32 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22

33
All notable changes to `nova-dependency-container` will be documented in this file.
44

5+
## [1.0.10] - 2025-11-25
6+
7+
### Fixed
8+
- Fixed FieldServiceProvider not correctly registering JavaScript assets with Nova
9+
- The previous `$app->resolving()` pattern was not working; switched to standard `Nova::serving()` pattern
10+
11+
### Changed
12+
- Refactored FieldServiceProvider to use the standard Nova asset registration pattern
13+
- Now properly imports `Laravel\Nova\Events\ServingNova` and `Laravel\Nova\Nova`
14+
15+
### Technical
16+
- This was the root cause of the Flexible field issue - the Vue components were never being loaded
17+
518
## [1.0.9] - 2025-11-25
619

720
### Added

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "iamgerwin/nova-dependency-container",
3-
"version": "1.0.9",
3+
"version": "1.0.10",
44
"description": "A Laravel Nova 4 and 5 field container allowing to depend on other fields values",
55
"keywords": [
66
"laravel",

docs/flexible-field-support.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ This ensures that changing a field in Overlay Item #1 doesn't affect the depende
168168

169169
## Version History
170170

171+
- **1.0.10**: Fixed FieldServiceProvider not registering assets with Nova
171172
- **1.0.9**: Added debug logging to diagnose Flexible field issues
172173
- **1.0.8**: Fixed missing compiled assets in package distribution
173174
- **1.0.7**: Fixed multi-group context contamination with 4-method detection approach

src/FieldServiceProvider.php

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,27 @@
55
namespace Iamgerwin\NovaDependencyContainer;
66

77
use Illuminate\Support\ServiceProvider;
8+
use Laravel\Nova\Events\ServingNova;
9+
use Laravel\Nova\Nova;
810

911
class FieldServiceProvider extends ServiceProvider
1012
{
13+
/**
14+
* Bootstrap any application services.
15+
*/
1116
public function boot(): void
1217
{
13-
if (class_exists('Laravel\Nova\Nova')) {
14-
$this->app->resolving('Laravel\Nova\Nova', function ($nova): void {
15-
\Laravel\Nova\Nova::serving(function ($event): void {
16-
\Laravel\Nova\Nova::script('nova-dependency-container', __DIR__ . '/../dist/js/field.js');
17-
\Laravel\Nova\Nova::style('nova-dependency-container', __DIR__ . '/../dist/css/field.css');
18-
});
19-
});
20-
}
18+
Nova::serving(function (ServingNova $event): void {
19+
Nova::script('nova-dependency-container', __DIR__ . '/../dist/js/field.js');
20+
Nova::style('nova-dependency-container', __DIR__ . '/../dist/css/field.css');
21+
});
22+
}
23+
24+
/**
25+
* Register any application services.
26+
*/
27+
public function register(): void
28+
{
29+
//
2130
}
2231
}

0 commit comments

Comments
 (0)