Skip to content

Commit

Permalink
ebess#337 Fix uploads with nested resources and multiple panels
Browse files Browse the repository at this point in the history
When a media upload is submitted from a parent resource form (e.g. media is associated on a user’s profile, but you want to edit the whole user from the user resource form), this ensures that the media upload is properly associated.

Signed-off-by: Tobias Grasse <tg@glancr.de>
  • Loading branch information
tobias-grasse committed Aug 21, 2023
1 parent 4cfce1d commit c57633b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Fields/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ public function uploadsToVapor(bool $uploadsToVapor = true): self
*/
protected function fillAttributeFromRequest(NovaRequest $request, $requestAttribute, $model, $attribute)
{
$attr = $request['__media__'] ?? [];
$data = $attr[$requestAttribute] ?? [];
$key = str_replace($attribute, '__media__.'.$attribute, $requestAttribute);
$data = $request[$key] ?? [];

if ($attribute === 'ComputedField') {
$attribute = call_user_func($this->computedCallback, $model);
Expand Down

0 comments on commit c57633b

Please sign in to comment.