nova-flexible-content: File fields "delete" button returns 404

The Delete button under a file field does not work correctly.

image

Nova responds with something like:

DELETE http://example.tld/nova-api/{resource}/{resourceId}/field/2011da1c6d582ce2__image 404 (Not Found)

This is because the fields inside a Flexible field do not exist in the resource’s root fields.

About this issue

  • Original URL
  • State: open
  • Created 8 years ago
  • Reactions: 12
  • Comments: 25 (4 by maintainers)

Commits related to this issue

Most upvoted comments

Yup, the issue lies here in FieldDestroyController in the handle method. As @Nyratas pointed out - when Nova tries to find the field by attribute it fails, because the field does not exist in the root.

$field = $resource->updateFields($request)
            ->whereInstanceOf(File::class)
            ->findFieldByAttribute($request->field, function () {
                abort(404);
            });

One of the solutions could be to overwrite the updateFields method on the resource by returning a custom FieldCollection instance which uses a different way to find fields by attribute. This could all be part of the package, you could just include a trait in your resource.

I might give it a go in the coming days.

On second inspection - overriding the availableFields method on the resource and applying a custom instance of the collection should do the trick.

Hi guys,

Just to clarify, “hard to read” not meaning it’s not good code, it is, meaning it’s hard to keep a mental model in one’s head of all the moving parts and track each variables actual value etc.

If you have not developed a Nova plugin and have not got a handle on the inner workings is quite daunting.

Thanks again for a great tool.