From b938468da126184e055220e7f91adae70ce0def6 Mon Sep 17 00:00:00 2001 From: Alexander Wenzel Date: Thu, 7 Jul 2022 12:54:08 +0200 Subject: [PATCH] added support for ebess/advanced-nova-media-library and fixed generell plugin behaviour (#5) --- readme.md | 9 +++++++-- src/DependencyContainer.php | 13 ++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index c63878f..d24e045 100644 --- a/readme.md +++ b/readme.md @@ -1,7 +1,12 @@ # nova 4 dependency container -A Laravel Nova 4 form container for grouping fields that depend on other field values. Dependencies can be set on any -field type or value. +A Laravel Nova 4 form container for grouping fields that depend on other field values. +Dependencies can be set on any field type or value. + +Features: + +- working form validation inside unlimited nested containers +- support of ebess/advanced-nova-media-library This plugin is based on [epartment/nova-dependency-container](https://github.com/epartment/nova-dependency-container) and only supports **Nova 4.x** and **PHP 8.x**. diff --git a/src/DependencyContainer.php b/src/DependencyContainer.php index 350d633..6ceed20 100644 --- a/src/DependencyContainer.php +++ b/src/DependencyContainer.php @@ -263,9 +263,20 @@ public function resolve($resource, $attribute = null) */ public function fillInto(NovaRequest $request, $model, $attribute, $requestAttribute = null) { + $callbacks = []; + foreach ($this->meta['fields'] as $field) { - $field->fill($request, $model); + /** @var Field $field */ + $callbacks[] = $field->fill($request, $model); } + + return function () use ($callbacks) { + foreach ($callbacks as $callback) { + if (is_callable($callback)) { + call_user_func($callback); + } + } + }; } /**