Skip to content

Commit

Permalink
added support for ebess/advanced-nova-media-library and fixed generel…
Browse files Browse the repository at this point in the history
…l plugin behaviour (#5)
  • Loading branch information
alexwenzel authored Jul 7, 2022
1 parent 0c9c600 commit b938468
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
9 changes: 7 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
@@ -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**.
Expand Down
13 changes: 12 additions & 1 deletion src/DependencyContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
};
}

/**
Expand Down

0 comments on commit b938468

Please sign in to comment.