Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propagate does not work with recursivity #22

Open
bozhidarampeco opened this issue Feb 8, 2024 · 3 comments
Open

Propagate does not work with recursivity #22

bozhidarampeco opened this issue Feb 8, 2024 · 3 comments
Labels
question Further information is requested

Comments

@bozhidarampeco
Copy link

bozhidarampeco commented Feb 8, 2024

Hello,

I had issues with recursivity, which wasn't working, then I saw this issue: #15 and I updated to 2.2.1, which fixed the recursivity, but now I noticed that the propagate does not work on the third level.

Example:

Resource1 has a HasManyNested(Resource2) field, Resource2 has a HasManyNested(Resource3) field

I want to propagate a property from Resource1 to Resource2 and then to Resource3.

It is propagated successfully to Resource2, but for Resource3 it is always null.

I tried adding a hidden field in Resource2 to propagate it, but it doesn't work again.

I tried propagating the value with a custom name, but this doesn't work as well.

Seems like all propagated properties are lost somewhere in this case.

Edit: in some cases when there are multiple requests triggered by Nova, in some requests the property is null even in Resource2 (so it works only sometimes even for Resource2).

@Lupennat
Copy link
Owner

Lupennat commented Feb 8, 2024

A field can only be propagated to its direct children; if you want to propagate the value of a field with a top-down strategy, you must propagate the value manually. Instead of creating a Hidden field in resource2 you can use the value key syntax

NestedMany(resource3)->propagate(['fieldxy' => $request->getNestedPropagated('fieldxy')])

Nova request that are not executed by NestedMany package/components can't have the propagated values.
if you provide me with a real example I can verify that it is not a bug.

@bozhidarampeco
Copy link
Author

Hi @Lupennat, thanks for your quick response!

Today I tested again and I found out that the way you suggested works, but if the value that is getting propagated from Resource1 changes, it causes requests that are refreshing the fields, and then it gives null for the property in Resource3.

This is only happening if I have 3 nested resources, if I only propagate from Resource1 (which holds the property originally and enables editing it) to Resource2 - it works.

I'm not sure what's the best way to give you a better example, should I create a separate repo with a demo project?

@Lupennat
Copy link
Owner

Lupennat commented Mar 8, 2024

certainly if you can provide me with a real testable example I can give you better insight.

@Lupennat Lupennat added the question Further information is requested label Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants