Feature Request: Pass 'resources' value to dependsOn PATCH calls for Actions #5549
-
|
It would be really handy to be able to retrieve the selected resource id/s (or 'all') when constructing the fields($request) array when using dependsOn functionality. this would fix the final piece of the puzzle when it comes to retrieving the select resource/s ids (or 'all') in the Action fields($request) method. if we have this information, it's possible to generate bespoke fields for a single resource (for example with values pre-filled) or to show different sets of fields when multiple (or all) resources are selected. this is very handy and allows for highly improved UX in some situations.
this allows us to lookup the model for the per-model actions generated in the the initial nova-api/resource/search call.
the very hacky solution i have implemented is to have a Hidden field 'action_resources' that contains the resources ids, and have the dependsOn field also depends on action_resources as well as whatever fields it really dependsOn. even though the dependsOn closure doesn't actually use this action_resources field, this crucially means that $request->action_resources will be included with the PATCH nova-api/resource/action?action=action-name&editing=true&editMode=create&field=... call. currently, the function i'm using to retrieve the selected model (or null for all/multiple models - which can be changed as necessary) is: so, if the real resources parameter could be added to the PATCH nova-api/resource/action?action=action-name&editing=true&editMode=create&field=... call, it would do away with the hidden field, the extra dependsOn requirement, and the action_resources parsing in the model($request) call. the only downside i can see is if you have a real field called 'resources' itself, but anyway when you actually confirm the action and it calls nova-api/resource/action?action=action-name&pivotAction=false&search=&filters=..., it will submit this field value as 'resources' anyway so it's not recommended to use this, and maybe even should throw an exception in Action when it finds a field called 'resources' perhaps? anyway i hope this is useful? if not for whatever reason, i'll keep using my hack and of course anyone else who finds this is free to use the same setup for now :) |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
|
i guess i forgot add to this - the whole point of my setup is the ability to use and then change the fields result based on this value :) |
Beta Was this translation helpful? Give feedback.
-
|
Duplicate of #5567 |
Beta Was this translation helpful? Give feedback.
-
|
is this fixed in Nova 4.25.0? in the release notes it claims: "Fixed an issue where selected resources were missing on action fields." but i am still seeing the same issue with 4.25.1 |
Beta Was this translation helpful? Give feedback.
Duplicate of #5567