advanced-nova-media-library icon indicating copy to clipboard operation
advanced-nova-media-library copied to clipboard

There was a problem submitting the form when insert new image in my resource

Open ghoreyshi opened this issue 2 years ago • 3 comments

Hello, I use advance-nova-media-library for upload image but after submite form, show error

Uploading 2022-06-14 00.02.58.jpg…

App\Models\File.php


namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;
use Spatie\MediaLibrary\MediaCollections\Models\Media;

class File extends Model implements HasMedia
{
    use HasFactory, InteractsWithMedia;

    public $fillable = [
        'file',
        'size',
        'format'
    ];

    public function registerMediaConversions(Media $media = null): void
    {
        $this->addMediaConversion('thumb');
    }

    public function registerMediaCollections(): void
    {
        $this->addMediaCollection('file');
    }
}


App\Nova\File.php


use Ebess\AdvancedNovaMediaLibrary\Fields\Images;
use Illuminate\Http\Request;
use Laravel\Nova\Fields\Avatar;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Image;
use Laravel\Nova\Fields\Number;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Http\Requests\NovaRequest;

class File extends Resource
{

     /**
     * Get the fields displayed by the resource.
     *
     * @param  \Laravel\Nova\Http\Requests\NovaRequest  $request
     * @return array
     */
    public function fields(NovaRequest $request)
    {
        return [
            ID::make()->sortable(),
            Text::make('format'),
            Number::make('size'),
            Images::make('file', 'file'),
        ];
    }
}

ghoreyshi avatar Jun 14 '22 07:06 ghoreyshi

I also get this error "There was a problem submitting the form" with a Nova 4 resource with multiple images:

Images::make('Images'),

In my case I think it's related to the media conversion:

    public function registerMediaConversions(Media $media = null): void
    {
        $this->addMediaConversion('image')
            ->width(500)
            ->height(500);
    }

If I remove this code the upload works...

Otherwise the Nova resource AJAX request is returning a 500 empty response:

?viaResource=&viaResourceId=&viaRelationship=&editing=true&editMode=update

I've tried debugging but no errors appearing in logs.

Any ideas?

benedict-w avatar Aug 26 '22 12:08 benedict-w

In my case the issue was GD failing silently. It turns out I needed to increase the PHP memory_limit for it to work!

benedict-w avatar Aug 31 '22 10:08 benedict-w

What's the issue here?

abrahamarslan avatar Dec 11 '22 11:12 abrahamarslan