nova-flexible-content icon indicating copy to clipboard operation
nova-flexible-content copied to clipboard

Nested layouts from preset will fail in resolver

Open pitylee opened this issue 3 years ago • 2 comments

Hello,

So I have seen lots of conversations about relations and nested flexibles, but after several attempts I did not succeed.

Have followed the docs and successfully set up the logic I need for the parent, which uses pivot table, and uses textautocomplete for the single field used in the layout. Upon saving, this will check if the same value exists, if not creates a new one, syncs and orders correctly.

This layout has another flexible field nested, which will behave diferently:

  • the first attribute of the resolver's setter method will fail, because in place of receiving the Resource as the main, it will receive a Layout which doesn't have the relationship method: ` // main $mains = $resource->mains()->get(); // receives Model

// sub $resource->subs()->get(); // will fail because $resource has no subs(), since it is Layout

// workaround for sub $sub = Sub::find($resource['id']); // this works sometimes, but sometimes the id is missing `

  • Am I mistaking, the Model should be the resource?
  • What am I doing wrong here?

pitylee avatar Jan 23 '22 19:01 pitylee